I`ve a datagrid on a windows forms.
Now i want to test online, which rows are selected.
One possibility is to use DataGrid.Isselected(index) in the idle time. But there must be a better way.
What i need is an event, like : OnselectingRow(), which is
fired everytime, the user selects a new row.
tnx for your helps.
ADAdministrator Syncfusion Team March 28, 2003 04:01 AM
I thinking looping through and checking IsSelected is teh simplest way for small grids (less than a couple hundred rows or so).
If you have thousands of rows, then this woul dnot make sense. You could add an ArrayList and track the selected rows yourself. When a row gets selected add teh index to the ArrayList, when teh row is de-selected, remove it from teh ArrayList.
To decide when a row is selected/de-selected, you could handle the MouseDown event and do a HitTest on teh point, checking to a row header hit. This FAQ has code that looks for a column header hit. The row header hit should be similar. Once you know row header was hit, you can look in your ArrayList to see whether you need to remove or add it.
How do I get the row or column that has been clicked on?