We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Selecting a row in a Datagrid

Hello! 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.

1 Reply

AD Administrator Syncfusion Team March 28, 2003 09:01 AM UTC

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? http://www.syncfusion.com/faq/winforms/search/785.asp

Loader.
Up arrow icon