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

Get corresponding DataRow for a grid row in hierarchical grid?

Thread ID:





15342 Jun 16,2004 02:27 PM UTC Jun 16,2004 10:44 PM UTC WinForms 3
Tags: GridControl
Asked On June 16, 2004 02:27 PM UTC

I have seen the topics for finding the DataRow for a corresponding grid row in the KB and Forums. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=14037 http://www.syncfusion.com/Support/article.aspx?id=10440 But...how can I get the DataRow for a child table in a hierarchical grid? I think I''m almost there, but can''t quite get it. It looks like the code from the above links gives me the DataRow for the correspdoning "parent" DataRow in the outer table. If the current selected cell is sitting on a row in the grid from a child table, I need to get that DataRow, not the parent one. CurrencyManager cm1 = (CurrencyManager)this.BindingContext[grid2.DataSource, "Categories"]; // outer table CurrencyManager cm2 = (CurrencyManager)this.BindingContext[grid2.DataSource, "Families"]; // inner table CurrencyManager cm3 = (CurrencyManager)this.BindingContext[grid2.DataSource, "Categories.Category_Family"]; // related table?! DataRow dr1 = ((DataRowView)cm1.Current).Row; DataRow dr2 = ((DataRowView)cm2.Current).Row; DataRow dr3 = ((DataRowView)cm3.Current).Row; Example: when on 2nd row of child records under the 2nd parent record, the above code gives: -- dr1 ends up as the parent table row. -- dr2 ends up as the first row of the child table under the first row of the parent table -- dr3 (based on the relation setup between the 2 tables) ends up as the first row of the child table under the second row of the parent table I''m not too familiar with BindingContext and CurrencyManager.Current -- should this "Current" property be in sync with what''s selected in the grid? Even in a hierarchical grid where, when sections are collapsed, grid rows are reordered/removed? I''ve looked at using RowIndexToListManagerPosition() but help docs say "Only the list manager position for the outer hierarchy is returned". Any thoughts?

Administrator [Syncfusion]
Replied On June 16, 2004 02:48 PM UTC

In a hierarchical grid, it is simpler to use the GridBoundRecordState. Here is some code.
GridBoundRecordState rs = this.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(gridRowIndex);
int pos = rs.Position;
CurrencyManager cm = rs.ListManager as CurrencyManager;
if(cm != null)
 DataView dv = cm.List as DataView;
 if(dv != null)
  DataRow dr = dv[pos].Row;
  Console.WriteLine(dr[0].ToString() + "  " + dr[1].ToString());

Replied On June 16, 2004 08:39 PM UTC

Thanks Clay! That works great. Just curious, where would I have found this GetRecordStateAtRowIndex to CurrencyManager to List (DataView) information? I''m learning mostly from reading these forums, but wondering where there is more overall docs on this stuff? The user guide is pretty high level, and the help integrated into vs.net is basically a reference, so you kinda have to know what you''re looking for. Thanks.

Administrator [Syncfusion]
Replied On June 16, 2004 10:44 PM UTC

We are working on better documentation. In general, for details and use cases, the samples are a good source of information. There are two samples that we ship that use GridBoundRecordState. It is a key object in hierarchical GridDataBoundGrids, and more information should be included in our User Guide and KB on this class.


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