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 the Position of a Row in the DataSource from the Current Record

Thread ID:

Created:

Updated:

Platform:

Replies:

119864 Aug 8,2015 04:21 AM UTC Aug 10,2015 01:49 PM UTC WinForms 1
loading
Tags: GridGroupingControl
Michael K
Asked On August 8, 2015 04:21 AM UTC

Dear Sir :

Good day , today I try to Get the Position of a Row in the DataSource from the Current Record, and your reference as below link 
http://help.syncfusion.com/ug/windows%20forms/index.html#!documents/howtogetthepositionofarowinthedatasourcefromthecurrentrecord.htm


Base on your sample , 

[C#]
 
Table table = e.TableControl.Table;
 
//Gets the current display element.
Element el = table.DisplayElements[e.rowIndex];
 
//Gets the current record.
Record r = el.ParentRecord;
 
//Finds its row position.
int dataRowPos = table.UnsortedRecords.IndexOf(r);
 
//Retrieves the corresponding data row from the datasource.
CustomersDataRow row = dataSoure.Rows[dataRowPos];
 
// Accesses the CutomerId value of the current record.
string id = row.CustomerId;

I would like to know what is the "e.rowIndex", as the select row index value may not complete event function

Thank you

Michael


Mahendran Annamalai [Syncfusion]
Replied On August 10, 2015 01:49 PM UTC

Hi Michael,

Thanks for using syncfusion products.

We have analyzed your query. In the mentioned code e.rowindex having value of CurrentCell located Rows index value. We have prepared work around sample by using TableControlCellClick event. We will update the same code snippet to mentioned  UGlink Please refer below code snippet.

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

{

    try

    {

        Table table = e.TableControl.Table;


        // Gets the current display element.

        Element el = table.DisplayElements[e.Inner.RowIndex];


        // Gets the current record.

        Record r = el.ParentRecord;

               

        //Finds its row position.

        int dataRowPos = table.UnsortedRecords.IndexOf(r);


        //Retrieves the corresponding data row from the datasource.

        DataRow dr = dt.Rows[dataRowPos];

               

        //Accesses the CutomerId value of the current record.or 1198

        this.textBox1.Text = dr["CustomerId"].ToString();


    }

    catch { }

}


And also we have attached workaround sample for this. Please find sample from below location.

Sample: GetRowPositionGC-CS


For more information, please refer KBLink.

Please let us know If you have any queries.

Thanks,
Mahendran.A

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

;