Gets the height to be used in for automatically 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 the cells automatically resize to.
The following example uses the GetPreferredHeight to return the height a column is automatically resized to.
[Visual Basic]
Private Sub GetAutoSize() Dim g As Graphics Set g = Me.CreateGraphics Dim AutoHeight As Long Dim dgeCol As DataGridTextBoxColumn ' Assuming column 1 of a DataGrid control is a DataGridTextBoxColumn. Set dgeCol = DataGrid1.GridColumns(1) ' Get the value contained by the cell using the CurrentCell. Dim myVal As Object myVal = dgeCol.DataGridTable.DataTable.Rows(DataGrid1.CurrentCell.RowNumber) AutoHeight = dgeCol.GetAutoResizeHeight(g, myVal) Debug.Print AutoHeight End Sub
DataGridTextBoxColumn Class | DataGridTextBoxColumn Members | System.WinForms Namespace | GetPreferredSize | GetMinimumHeight