Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
How i can get the Datagridcell object from datagrid.
I am getting selected Cell but i also to want unselected cell. How i can achieve this. Please suggest something.
Posted
Comments
creepz03 21-Dec-13 1:18am    
Then you should use the row databaound event to get each cell.
Member 10284439 21-Dec-13 2:49am    
i want on selection change

1 solution

Not sure what your trying to say, but if you mean how do I unselect a selected cell...

for a single cell:
// Cell, DataGridView[columnindex, rowindex]
MyGrid[0, 0].Selected = false;


for all selected cells:
if(MyGrid.SelectedCells.Count != 0)
     for(int i = 0; i < MyGrid.SelectedCells.Count; i++){
          MyGrid.SelectedCells[i].Selected = false;
     }


you may need to call invaliate on the DataGridView to reflect the changes.
//Invalidate, DataGridView to redraw its surface.
MyGrid.Invalidate();
 
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