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

Looping table Elements

Thread ID:





27493 Apr 13,2005 03:38 PM UTC Apr 13,2005 11:44 PM UTC WinForms 1
Tags: GridControl
Administrator [Syncfusion]
Asked On April 13, 2005 03:38 PM UTC

Hi, in my current program i am looping all elements searching for GridNestedTables with the following code: foreach (Element em in m_syncGrid.Table.Elements) { if (em is GridNestedTable) { ... this works fine. After looping all elements i am looping all gridgroupingControl1.Table.Records. Now i''m wondering if i could get a reference to each record when looping the elements ?? I want to avoid looping the grid twice. If you could tell me what i would have to cast the element to would be great. I already tried record and others but either i don''t get any hit or the element cannot be casted in a usable manner. Thanks

Administrator [Syncfusion]
Replied On April 13, 2005 11:44 PM UTC

If you want to get at the recrods in a GriNestedTable, you need to drill down until there is no longer a gridnestedtable as the element being looked at.
int i = 0;
foreach(Element el in this.gridGroupingControl1.Table.Elements)
	Console.WriteLine("{0}-{1}", i, el.GetType());
	i += 1;

	if(el != null)
		if(el is GridRecord)
			DataRowView drv = (el as Record).GetData() as DataRowView;
			Console.WriteLine(drv[1].ToString()); //show column 2
		else if(el is GridNestedTable)
			GridNestedTable gnt = el as GridNestedTable;
			GridNestedTable gnt1 = gnt;
			while(gnt1 != null && gnt1.ChildTable != null)
				gnt = gnt1;
				gnt1 = gnt.ChildTable.ParentTable.CurrentElement as GridNestedTable;
			foreach(GridRecord r in gnt.ChildTable.ParentTable.Records)
				DataRowView drv = r.GetData() as DataRowView;
				if(drv != null)
					Console.WriteLine(drv[1].ToString()); //show column 2


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

or the page will be automatically redirected to 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