Small is New Big in C#


How can i create frozen datagridview at RowCount – 1

leave a comment »

I have create an row Total at bottom DataGridview and I would like to
fix this Row always show in DataGridView.

Can I frozen this this Row (position: RowCount – 1) out of bug when
DataGridView have Scrolls?

Has Anyone got other way to always this row?

//I think you want add new row to datagridview's bottom, I have written a sample to you. 

private int sum;

private void frmMain_Load(object sender, EventArgs e)
DataSet ds = db.GetDataSet("select * from tb_InputGoods", "tb_InputGoods"); //Get your dataset

//--------- sum total --------//
DataRow dr = ds.Tables[0].NewRow();
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
sum = Convert.ToInt16(ds.Tables[0].Rows[i][8]) + sum;
dr[8] = sum;
dataGridView1.DataSource = ds.Tables[0];


Written by nauhil

June 14, 2010 at 11:05 am

Posted in Q&A

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: