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

Location of current row in grid with nested relations...

Thread ID:





9166 Dec 9,2003 10:33 AM UTC Dec 10,2003 07:40 AM UTC WinForms 4
Tags: GridControl
Administrator [Syncfusion]
Asked On December 9, 2003 10:33 AM UTC

How could I locate the current row in my DataTable if the current table is not the root table in a nested relation?

Administrator [Syncfusion]
Replied On December 9, 2003 12:26 PM UTC

I tried this(from a class derived from GridDataBoundGrid): CurrencyManager cm = (CurrencyManager)BindingContext[this.DataSource, "NameOfTableInNestedRelation"]; int index = cm.Position; This is only working if the DataMember is the name of the root table of the DataSet.

Administrator [Syncfusion]
Replied On December 9, 2003 01:10 PM UTC

It is not too easy to get the position in the original table, but it is pretty straight forward to retrieve tbe item itself. Below is some code. If you need the position, then you could try to find the retrieved item in the table somehow.
private void button1_Click(object sender, System.EventArgs e)
	GridCurrentCell cc = grid.CurrentCell;
	GridBoundRecordState rs = grid.Binder.GetRecordStateAtRowIndex(cc.RowIndex);
	DataRowView drv = rs.Table[rs.Position] as DataRowView;
	Console.WriteLine(drv[0].ToString() + " -- " + drv[1].ToString());

Administrator [Syncfusion]
Replied On December 10, 2003 07:16 AM UTC

Thanks!! Now I have the row index in the source table. (I compared the drv.Row with each row in the DataTable object...) Is there also a way to get the column index? I did not find a way.

Administrator [Syncfusion]
Replied On December 10, 2003 07:40 AM UTC

Try this: int field = this.grid.Binder.ColIndexToField(cc.ColIndex);


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