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. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to get value of cell of particular row from gridgrouping control

Thread ID:

Created:

Updated:

Platform:

Replies:

117537 Nov 5,2014 11:57 AM UTC Sep 4,2015 09:05 AM UTC WinForms 3
loading
Tags: GridGroupingControl
Rasika
Asked On November 5, 2014 11:57 AM UTC

Hi,
I am using gridgrouping control.
I want to fetch the value of cell of selected row from gridgrouping control.
Is any method for this?
Please give me any solution regarding to this issue.
 
Regards,
Rasika

Neelakandan Kannan [Syncfusion]
Replied On November 7, 2014 05:24 AM UTC

Hi Rasika,

 

Thank you for your interest in Syncfusion products.

 

Query

How to get cell value from selected row?

Method-1:

 

If you want to get the value of cell from selected row while using Allow Selection property, you can use TableControlCellClick event. You can get cell value of selected row using GetSelectedRows method and element class. Please make use of below code and attached sample,

 

this.gridGroupingControl1.TableOptions.AllowSelection = GridSelectionFlags.Row;

void gridGroupingControl1_TableControlCellClick(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellClickEventArgs e)

        {

            if (this.gridGroupingControl1.TableModel[e.Inner.RowIndex, e.Inner.ColIndex].CellType == "RowHeaderCell") //To check whether it is RowHeader

            {

                var s = this.gridGroupingControl1.Table.SelectedRecords;

                GridRangeInfoList s1 = this.gridGroupingControl1.TableModel.Selections.GetSelectedRows(true, true);//to get row index range

                foreach (GridRangeInfo info in s1)

                {

                    Element el = this.gridGroupingControl1.TableModel.GetDisplayElementAt(info.Top);

                    string cellValue = el.GetRecord().GetValue("SupplierID").ToString();//to get cellvalue of particular column from selected row.          

                }

            }

        }

 

 

Method-2

 

If you want to get the value of cell from selected row while using ListBoxSelectionMode property, you can use SelectedRecordsChanging

event.

 

this.gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.MultiExtended;

void gridGroupingControl1_SelectedRecordsChanging(object sender, Syncfusion.Grouping.SelectedRecordsChangedEventArgs e)

        {                    

           GridRangeInfoList s1= this.gridGroupingControl1.TableModel.Selections.GetSelectedRows(true, true);

           foreach (GridRangeInfo info in s1)

           {

               Element el = this.gridGroupingControl1.TableModel.GetDisplayElementAt(info.Top);

               string str = el.GetRecord().GetValue("SupplierID").ToString();

           }

        }

 

 

Please let me know if you have any concerns.

 

Regards,

Neelakandan


Attachment: Getting_Started_Demo_36ad39a1.zip

Gregory Pe
Replied On September 3, 2015 12:22 PM UTC

Hi,
I added
private void button1_Click(object sender, EventArgs e)
        {
            this.gridGroupingControl1.TableOptions.AllowSelection = GridSelectionFlags.Row;

            GridRangeInfoList s1 = this.gridGroupingControl1.TableModel.Selections.GetSelectedRows(true, true);
            foreach (GridRangeInfo info in s1)
            {
                Element el = this.gridGroupingControl1.TableModel.GetDisplayElementAt(info.Top);
                string cellValue = el.GetRecord().GetValue("SupplierID").ToString();
                MessageBox.Show("" + cellValue);
            }

        }
question:
why not show the following selected values: 9,10,11


Regards,
Grzegorz



Attachment: test003_319e916b.zip

Adhikesevan Kothandaraman [Syncfusion]
Replied On September 4, 2015 09:05 AM UTC

Hi Grzegorz,

Thanks for the update.

The GridRangeInfoList is the collection of individual ranges in the grid. To retrieve the rows from the GridRangeInfoList, we need to loop through the inner elements of GridRangeInfo which is retrieved from the GridRangeInfoList. Since, the Grid have the multiple selection ranges. Each range contains information about the selected rows separately. Please refer to the below code example,

Code Snippet:

private void button1_Click(object sender, EventArgs e)

{

    this.gridGroupingControl1.TableOptions.AllowSelection = GridSelectionFlags.Row | GridSelectionFlags.AlphaBlend;


    GridRangeInfoList s1 = this.gridGroupingControl1.TableModel.Selections.GetSelectedRows(true, true);

    foreach (GridRangeInfo info in s1)

    {

        string cellValue = "";

        //loop through the internal GridRangeInfo

        for (int i = info.Top; i <= info.Bottom; i++)

        {

            Element el = this.gridGroupingControl1.TableModel.GetDisplayElementAt(i);

            cellValue += "SupplierID = "+ el.GetRecord().GetValue("SupplierID").ToString() +"\n";                  

        }               

        MessageBox.Show("" + cellValue);

    }
}

Sample:
http://www.syncfusion.com/downloads/support/forum/117537/ze/Getting_Started_Demo1206885293

Regards,
Adhi.


CONFIRMATION

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.

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

;