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

Reg : Groupinggrid to DataTable

Thread ID:

Created:

Updated:

Platform:

Replies:

32479 Aug 2,2005 04:41 AM UTC Aug 2,2005 09:01 AM UTC WinForms 1
loading
Tags: GridControl
Anna Srinivasan
Asked On August 2, 2005 04:41 AM UTC

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 09:01 AM UTC

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.

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

;