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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

RowHeight on QueryColumnWidth

Thread ID:





32284 Jul 26,2005 05:15 PM UTC Jul 26,2005 06:44 PM UTC WinForms 2
Tags: GridControl
Administrator [Syncfusion]
Asked On July 26, 2005 05:15 PM UTC

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?

Administrator [Syncfusion]
Replied On 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.

Administrator [Syncfusion]
Replied On 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


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon