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.

Bounding Dataset to GridControl

Thread ID:

Created:

Updated:

Platform:

Replies:

29493 May 26,2005 03:00 AM May 26,2005 03:50 AM Windows Forms 1
loading
Tags: GridControl
Lea Nutman
Asked On May 26, 2005 03:00 AM

Hello, Is there a way to bound a dataset into a GridControl ? (We need to use GridControl and can not GridDataBoundGrid Control due to the fact that we need cell style and row style features) Thanks in advance, Lea

Administrator [Syncfusion]
Replied On May 26, 2005 03:50 AM

There are a couple ways t do this. One is to move the data from the Datatable into the grid. You can use grid.PopulateValues to do this. //dt is a datatable this.gridControl1.BeginUpdate(); int nCols = dt.Columns.Count; int nRows = dt.Rows.Count; this.gridControl1.ColCount = nCols; this.gridControl1.RowCount = nRows; this.gridControl1.PopulateValues(GridRangeInfo.Cells(1, 1, nRows, nCols), dt); this.gridControl1.EndUpdate(); this.gridControl1.Refresh(); If you want to save things only at the end, then you can handle the SaveCellInfo event and store a ''changed flag'' in the grid[e.RowIndex, 0].Tag to indicate a row has been changed. And then whne you are ready to save the changes, you can loop through the rows looking at these Tags to move the changes back to the DataTable. If you want to change the DataTable dynamically as he changes take place in teh grid, you can do that directly in SaveCellInfo. (But do not set e.handled = true as you still want the grid to update in cell style cache.) If you do not want to call PopulateValues to actually move the values from theh DataTable to the grid, you can also handle the QueryCellInfo event, and dynamically set e.Style.CellValue from the DataTable based on the e.RoeIndex and e.ColIndex passed it.

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.

;