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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

9166 Dec 9,2003 05:33 AM Dec 10,2003 02:40 AM Windows Forms 4
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On December 9, 2003 05:33 AM

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 07:26 AM

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 08:10 AM

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 02:16 AM

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 02:40 AM

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

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.

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.

;