NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

DataGridTextBoxColumn.GetPreferredHeight

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;

Parameters

g
A Graphics object used to draw shapes on the screen.
value
The value to draw.

Return Value

The height the cells automatically resize to.

Example [Visual Basic]

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

See Also

DataGridTextBoxColumn Class | DataGridTextBoxColumn Members | System.WinForms Namespace | GetPreferredSize | GetMinimumHeight