Gets the height used when resizing columns.
[Visual Basic] Overrides Public Function GetPreferredHeight( _ ByVal g As Graphics, _ ByVal value As Object _ ) As Integer [C#] public override int GetPreferredHeight( Graphics g, object value ); [C++] public: override int GetPreferredHeight( Graphics* g, Object* value ); [JScript] public override function GetPreferredHeight( g : Graphics, value : Object ) : int;
The height used to automatically resize cells in a column.
The following example uses the GetPreferredHeight to return the height required to draw a given value. The font size is changed, and a new height returned.
[Visual Basic]
Private Sub GetAutoSize() Dim obj As Object Dim g As Graphics obj = "a string" Set g = Me.CreateGraphics Dim sze As Integer sze = datagrid1.GridColumns(0).GetPreferredHeight(g, obj) Debug.Print sze Set datagrid1.Font = New System.Drawing.Font("Times Roman", 24!) sze = datagrid1.GridColumns(0).GetPreferredHeight(g, obj) Debug.Print sze End Sub
DataGridBoolColumn Class | DataGridBoolColumn Members | System.WinForms Namespace | GetPreferredSize | GetMinimumHeight