Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
24281 | Feb 1,2005 12:37 AM UTC | Feb 1,2005 07:11 AM UTC | WinForms | 1 |
![]() |
Tags: GridControl |
//total height
int h = this.grid.Model.RowHeights.GetTotal(0, this.grid.Model.RowCount + 1);
//width of, say, 5 columns
int w = this.grid.Model.ColWidths.GetTotal(0, 5);
this.grid.ClientSize = new Size(w, h);
If grid is a GriddataBoundGrid in the above code, there is some autosizing that is done at the initial display. If you want to control the size of the grid based on colwidths, then this autosizing will throw your calculations off. So, you would need to turn this off using grid.AllowAutoSize = false. You could also call grid.Model.ColWidths.ResizeToFit yourself if you still wanted the autozing after turning off the automatic autosizing at initial display, but you would want tto do it before the above code.
this.gridDataBoundGrid1.AllowResizeToFit = false;
this.gridDataBoundGrid1.Model.ColWidths.ResizeToFit(GridRangeInfo.Table(), GridResizeToFitOptions.IncludeHeaders);
//total height
int h = this.gridDataBoundGrid1.Model.RowHeights.GetTotal(0, this.gridDataBoundGrid1.Model.RowCount + 1);
//width of, say, 5 columns
int w = this.gridDataBoundGrid1.Model.ColWidths.GetTotal(0, 5);
this.gridDataBoundGrid1.ClientSize = new Size(w, h);
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.
This page will automatically be redirected to the sign-in page in 10 seconds.