How to access to a row selected by the user ?

Hello Dear Sir,
Firstly, I would thank you for your help.
My question is how to read the value of the Cell of a row selected by the user.
Best regards

1 Reply

AR Arulpriya Ramalingam Syncfusion Team December 27, 2017 12:05 PM UTC

Hi Cosyspro,  
  
Thanks for contacting Syncfusion support.  
  
As per the grid architecture, the selected rows will be added to SelectedRecords collection when the ListBoxSelectionMode is enabled and the selected rows will be added toSelectedRanges collection when the AllowSelection is enabled. The selected rows/records can be retrieved from the SelectedRanges/SelectedRecords collection and the cell value of selected records can be retrieved by using the GetValue() method of Record. We have created a simple sample as per your requirement. Please make use of below KB and sample,  
  
Code snippet  
  
//When ListBoxSelectionMode is enabled  
if (this.gridGroupingControl1.Table.SelectedRecords.Count > 0)  
{  
    foreach (SelectedRecord selectedRecord inthis.gridGroupingControl1.Table.SelectedRecords)  
    {  
        //To get the cell value of particular column of selected records  
        string cellValue = selectedRecord.Record.GetValue("Name").ToString();  
        MessageBox.Show(cellValue);  
    }  
}  
//When AllowSelection is enabled  
if(this.gridGroupingControl1.TableModel.SelectedRanges.Count > 0)  
{  
    foreach(GridRangeInfo range inthis.gridGroupingControl1.TableModel.SelectedRanges)  
    {  
        Record record =this.gridGroupingControl1.TableModel.GetDisplayElementAt(range.Top).GetRecord();  
        //To get the cell value of particular column of selected records  
        string cellValue = record.GetValue("Name").ToString();  
        MessageBox.Show(cellValue);  
    }  
}  
  
  
  
Regards,  
Arulpriya  


Loader.
Up arrow icon