Click here to Skip to main content
15,880,299 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello guys...

How can i disable the last row or the last data in the datagrid when the user wants to sort by clicking column header.
I just want the last data to be always in the last row, cause it is the "TOTAL" or "AVERAGE" or the "SUM" of the data.

Please help...

Thanks in advanced..

DataGridView1.DataSource = dt
DataGridView1.Rows(DataGridView1.RowsCount- 1).DefaultCellStyle.BackColor = Color.Gray
DataGridView1.Rows(DataGridView1.RowsCount-1).ReadOnly = True
Share this answer
I will suggest you to use footer template of datagrid for the total and average.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900