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.

How to use a datatable as a data source ?

Thread ID:

Created:

Updated:

Platform:

Replies:

44268 May 18,2006 12:03 PM May 19,2006 09:34 AM Windows Forms 2
loading
Tags: GridControl
Amit Weisman
Asked On May 18, 2006 12:03 PM

How to use a datatable as a data source ? Hi, I must be missing something. I would like to populate my grid control (windows application) by using a datatable. I looked at the samples and searched the KB and forum and I know that I can use this row: this.gridControl1.Model.PopulateValues (GridRangeInfo.Cells(1,1, numberofrows, numberofcolumns), dt); But I lost all the style information, mainly the columns names. I’l looking for something like : Gridcontrol.Model.DataSource = dt ; Where this option is hiding ? Thanks Amit

WindowsApplication48.zip

Administrator [Syncfusion]
Replied On May 18, 2006 11:47 PM

Hi Amit , PopulateValues method gives you an easy way to copy data from any given datasource that implements the IList interface or is a Array to specified range of cells in the grid. It does n''t copy the datatable column header information. Do you want to display the datatable column header information on the grid?. You need to handle the QueryCellInfo event to set the cell text of the header row(0 th row) in a grid. Here is a code snippet. if(e.RowIndex == 0 && e.ColIndex > 0 && dt.Columns.Count >= e.ColIndex ) { e.Style.Text = dt.Columns[e.ColIndex - 1].ColumnName; } Here is a modified sample. http://www.syncfusion.com/Support/user/uploads/WindowsApplication48_3cea37c8.zip Please let me know if this helps. Best Regards, Haneef

Amit Weisman
Replied On May 19, 2006 09:34 AM

Thanks Haneef.

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.

;