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.

Reg : Groupinggrid to DataTable

Thread ID:

Created:

Updated:

Platform:

Replies:

32479 Aug 2,2005 12:41 AM Aug 2,2005 05:01 AM Windows Forms 1
loading
Tags: GridControl
Anna Srinivasan
Asked On August 2, 2005 12:41 AM

Hi, I am using following code to copy data from grid to datatable. I am facing problem like... I dont want to copy first three column from grid.(Always) How do i do that...? DataTable dt = new DataTable(); int numCols = grid.TableDescriptor.VisibleColumns.Count; foreach(GridVisibleColumnDescriptor cd in grid.TableDescriptor.VisibleColumns) { string s = grid.TableDescriptor.Columns[cd.Name].HeaderText; dt.Columns.Add(new DataColumn(s, grid.TableDescriptor.Columns[cd.Name].FieldDescriptor.GetPropertyType())); } foreach(Record r in grid.Table.FilteredRecords) { DataRow dr = dt.NewRow(); foreach(GridVisibleColumnDescriptor cd in grid.TableDescriptor.VisibleColumns) { string s = grid.TableDescriptor.Columns[cd.Name].HeaderText; dr[s] = r.GetValue(cd.Name); } dt.Rows.Add(dr); } dt.AcceptChanges(); Thanks, Anna

Administrator [Syncfusion]
Replied On August 2, 2005 05:01 AM

Try adding code to both the loops that will skip the first three passes through the loops.
int numCols = grid.TableDescriptor.VisibleColumns.Count;
int i = 0;
foreach(GridVisibleColumnDescriptor cd in grid.TableDescriptor.VisibleColumns)
 {
	if(i > 2)
	{
		string s = grid.TableDescriptor.Columns[cd.Name].HeaderText;
		dt.Columns.Add(new DataColumn(s, 		grid.TableDescriptor.Columns[cd.Name].FieldDescriptor.GetPropertyType()));
	}
	i += 1;
}

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.

;