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

c# winforms sfDataGrid multiple selected cells

Hello,

i have the following code which gives me the value in cell 0 of the selected row.

            string idtoapp;
            var selectedItem = sfDataGrid3.SelectedItems[0];
            var dataRow = (selectedItem as DataRowView).Row;
            idtoapp = dataRow["id"].ToString();

i wish to use multiple selection and return all values of cell 0 from the rows that are selected.

your help would be mostly appreciated.

Many Thanks

Matt 





3 Replies

JP Jagadeesan Pichaimuthu Syncfusion Team April 10, 2019 01:37 AM

Hi Matt, 

Thanks for using Syncfusion product. 

You can able to get the all 0th column value of the selected rows by using the below code snippet, 

List<string> items = new List<string>(); 
 
if (sfDataGrid1.SelectedItems.Count > 0) 
{ 
    foreach (var item in sfDataGrid1.SelectedItems) 
    { 
        var dataRow = (item as DataRowView).Row; 
        string selectedItem = dataRow[0].ToString(); 
        items.Add(selectedItem); 
    } 
} 


If we misunderstood your requirement, please provide more information regarding the requirement. This would help us to proceed further. 

Regards, 
Jagadeesan


MA Matt April 11, 2019 09:57 AM

Hello,

This was perfect 

Thank you so much. 


JP Jagadeesan Pichaimuthu Syncfusion Team April 11, 2019 11:31 PM

Hi Matt, 
 
Thanks for your update. 
 
We are glad to know that the provided solution worked at your end. Please let us know if you have any further queries on this. We are happy to help you. 
 
Regards, 
Jagadeesan

Loader.
Live Chat Icon For mobile
Up arrow icon