2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
Resize the row heightIn order to resize the row height based on the cell content height, the ResizingRows event can be used. The resizing value is calculated from the content height using MeasuringString() method. The rows individually can be resized using the AllowResizingIndividualRows() method of GridHelperclasses. C# GridEngineFactory.Factory = new Syncfusion.GridHelperClasses.AllowResizingIndividualRows(); gridControl1.ResizingRows += gridControl1_ResizingRows; Size stringSize; void gridControl1_ResizingRows(object sender, GridResizingRowsEventArgs e) { if (e.Reason == GridResizeCellsReason.DoubleClick) { Graphics grapics = CreateGraphics(); long maxHeight = 0; GridStyleInfo style = this.gridControl1.GetViewStyleInfo(e.Rows.Bottom, 1); stringSize = grapics.MeasureString(style.Text, style.GdipFont).ToSize(); if (maxHeight < stringSize.Height) { maxHeight = (long)stringSize.Height; } this.gridControl1.Model.RowHeights[e.Rows.Bottom] = (int)maxHeight; e.Cancel = true; } }
VB GridEngineFactory.Factory = New Syncfusion.GridHelperClasses.AllowResizingIndividualRows() AddHandler gridControl1.ResizingRows, AddressOf gridControl1_ResizingRows Dim stringSize As Size void gridControl1_ResizingRows(Object sender, GridResizingRowsEventArgs e) If e.Reason = GridResizeCellsReason.DoubleClick Then Dim grapics As Graphics = CreateGraphics() Dim maxHeight As Long = 0 Dim style As GridStyleInfo = Me.gridControl1.GetViewStyleInfo(e.Rows.Bottom, 1) stringSize = grapics.MeasureString(style.Text, style.GdipFont).ToSize() If maxHeight < stringSize.Height Then maxHeight = CLng(Fix(stringSize.Height)) End If Me.gridControl1.Model.RowHeights(e.Rows.Bottom) = CInt(Fix(maxHeight)) e.Cancel = True End If
Screenshot Samples: C#: RowHeight_CS VB: RowHeight_VB
|
2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.