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

How to use a datatable as a data source ?

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

2 Replies

AD Administrator Syncfusion Team May 19, 2006 03:47 AM UTC

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


AW Amit Weisman May 19, 2006 01:34 PM UTC

Thanks Haneef.

Loader.
Live Chat Icon For mobile
Up arrow icon