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.

GridDataBoundGrid.Model.RowCount

Thread ID:

Created:

Updated:

Platform:

Replies:

26626 Mar 28,2005 09:09 PM Mar 29,2005 04:35 AM Windows Forms 2
loading
Tags: GridControl
Daniel Byers
Asked On March 28, 2005 09:09 PM

In code below, I attempt to attach a DataTable to a GDBG. This grid is then used by the ExcelRW to create a worksheet. After this code runs, grid.Model.RowCount returns 0 despite the fact that there are 11 rows (grid.Model.ColCount) properly returns 2 because there are two columns. Where are my rows? They are in the datatable... GridDataBoundGrid grid = new GridDataBoundGrid() ; grid.BeginInit() ; //had to do in order for the Binder to be defined??? grid.EndInit() ; GridBoundColumn gbc = new GridBoundColumn() ; gbc.MappingName = "Name" ; gbc.HeaderText = "" ; grid.Binder.GridBoundColumns.Add(gbc) ; gbc = new GridBoundColumn() ; gbc.MappingName = "Value" ; gbc.HeaderText = "" ; grid.Binder.GridBoundColumns.Add(gbc) ; grid.DataBoundGridModel.BeginUpdate() ; grid.Binder.SuspendBinding() ; grid.Binder.DataSource = dt ; //contains 11 rows - confirmed grid.Binder.ResumeBinding() ; grid.DataBoundGridModel.EndUpdate() ;

Daniel Byers
Replied On March 28, 2005 09:51 PM

This apparently affects the ColWidths collection as well?? Is this because the grid is never actually drawn?

Administrator [Syncfusion]
Replied On March 29, 2005 04:35 AM

Yes. The colwidths sizings are not set until the grid is displayed. Likely calling grid.Refresh after the code you listed will make grid.Model.RowCount reflect the proper value, but it may not set the colwidths. If not, you can try explicitly calling: grid.AllowResizeToFit = false; grid.Model.ColWidths.ResizeToFit(GridrangeInfo.Table(), GridResizeToFitOptions.IncludeHeaders);

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.

;