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
close icon

Dynamically setting Header Row Size

Hi I have a grid which has different length Column header names.Intially, when the grid is loaded all the columns get clustered and i have manually resize each column to view the contents. Also I cannot set the height and width of each column as there are more than 100 column on the grid.To avoid this i have used the following steps : 1. Created a range of all cells in Column header row. 2.Used RowHeights.ResizeToFit property. Code: >>Syncfusion.Windows.Forms.Grid.GridRangeInfo objGridInfo = new >>Syncfusion.Windows.Forms.Grid.GridRangeInfo(); objGridInfo =dgAnalysis.Model.Rows.CreateRangeFromTo(0,0); >>dgAnalysis.Model.RowHeights.ResizeToFit(objGridInfo,Syncfusion.Windows.Forms.Grid.GridResizeToFitOptions.IncludeHeaders) ; But this code does not work always. Can you suggest what is wrong in this code. And also if something else that i can try to solve the problem.

1 Reply

AD Administrator Syncfusion Team July 26, 2004 07:24 AM UTC

If this is a GridDataBoundGrid, in formload, also set grid.AllowResizeToFit = false. The reason is that if this is not set, the grid will try to set the colwidths itself, and this can ''step on'' the explicit sizing you want to do. Not that I think it will make a difference, but you do not have to use a new operator to generate a GridRangeInfo object as the class has Static constructors that simpleify things in this respect. This single line can replace all teh code you listed. grid.Model.RowHeights.ResizeToFit(GridRangeInfo.Row(0), GridResizeToFitOptions.IncludeHeaders);

Live Chat Icon For mobile
Up arrow icon