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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Selecting a row in a Datagrid

Thread ID:





3508 Mar 26,2003 12:23 PM UTC Mar 28,2003 09:01 AM UTC WinForms 1
Tags: FAQ
Asked On March 26, 2003 12:23 PM UTC

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.

Administrator [Syncfusion]
Replied On 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


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon