Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > about datagridview to show total at footer
 

about datagridview to show total at footer

hi all

i have windows application in which a form containing datagridview is there.

in that datagridview i want to show total of values of one column at bottom.

i dont know how to do that

can anyone help me

Surrendra  Saturday, August 19, 2006 6:43 AM

You can iterate through all the cells in the column and add the values for each cell. You can then display the total in all cell you want to.

int rowCount = datagridview.Rows.Count;

int columnIndex = datagridview.Columns[columnName].Index;

int sum = 0;

for (int i = 0; i < rowCount; i++)

{

sum += datagridview[columnIndex, i];

}

datagridview[columnIndex, rowCount+1].Value = sum;

This should work.

Thanks,

Rashmi

Rashmi Gopinath  Monday, August 21, 2006 9:14 PM

hi rashmi

thanx for ur reply

but in which event of datagrid view should i use this code? can u suggested me any event......

Surrendra  Tuesday, August 22, 2006 4:13 AM

Hi,

It would be Great if i have that Total value in the footer of the datagrid and through the client side scripting, we want to show the total value on the onBlur event of the Text Boxes (Inside onr of the columns of the datagrid).

regards,

Imtiyaz

(.Net Developer)

Imtiyaz Thange  Wednesday, October 11, 2006 8:40 AM

You can use google to search for other answers

Custom Search

More Threads

• How to create the multiple headers in DataGridView
• DataGridViewComboBoxCell null reference
• add rows to bound datatable
• Creating a preview page before submitting info to database
• Drag Drop filename fron datagridview row to external notepad application?
• append rows to a datagrid
• SetDataBinding syntax help.
• How to Sort with BindingSource.Sort Property Case-Sensitive.
• Trouble with owner-draw for ListBox control
• Datagridview - generic display