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

RowHeight on QueryColumnWidth

Hopefully someone will be able to help...I''ve been banging my head against the wall over this for awhile. I have a grid in which has 1 data column, where the column is stretched to fill the client window size using the following code: ''=================================== Private Sub GridControl1_QueryColWidth(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridRowColSizeEventArgs) Handles gridControl1.QueryColWidth If e.Index = gridControl1.ColCount Then Dim width As Integer = IIf(gridControl1.ColCount <= 0, 0, gridControl1.ColWidths.GetTotal(0, gridControl1.ColCount - 1)) e.Size = gridControl1.ClientRectangle.Width - width e.Handled = True End If End Sub ''=================================== This works fine...however some of the data cells contain a lot of data, and after a client resize, I would also like the height of the cell to grow/shrink to better fit the data. When I include the obvious solution "grid.model.rowheight.resizeTofit"...I get a stack overflow exception. I''ve realized this is because resizeToFit recursively calls queryColumnWidth, so were stuck in an endless loop. Is there any better way to get the preffered column height without calling ResizeToFit?

2 Replies

AD Administrator Syncfusion Team July 26, 2005 05:47 PM UTC

If you only want to call ResizeToFit when the client gets resized, then try calling it from the grid.SizedChanged event to see if that will work for you.


AD Administrator Syncfusion Team July 26, 2005 06:44 PM UTC

Perfect...thanks for the tip! if anyone else is interested, this code works: Private Sub gridControl1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gridControl1.SizeChanged Dim cw As Integer = gridControl1.ColWidths.GetTotal(0, gridControl1.ColCount - 1) cw = gridControl1.ClientRectangle.Width - cw gridControl1.Model.ColWidths.SetSize(1, cw) gridControl1.Model.RowHeights.ResizeToFit(GridRangeInfo.Col(1)) gridControl1.Refresh() ''gridControl1.Model.ColWidths.ResizeToFit(GridRangeInfo.Col(1)) End Sub

Loader.
Live Chat Icon For mobile
Up arrow icon