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!

DataGridColumn.GetPreferredHeight

When overridden in a derived class, gets the height to be used in for automatically resizing columns.

[Visual Basic]
MustOverride Public Function GetPreferredHeight( _
   ByVal g As Graphics, _
   ByVal value As Object _
) As Integer
[C#]
public abstract int GetPreferredHeight(
   Graphics g,
   object value
);
[C++]
public: virtual int GetPreferredHeight(
   Graphics* g,
   Object* value
) = 0;
[JScript]
public abstract function GetPreferredHeight(
   g : Graphics,
   value : Object
) : int;

Parameters

g
A Graphics object.
value
A object value for which you want to know the screen height and width.

Return Value

The height used for auto resizing a cell.

Remarks

The GetPreferredSize will usually be invoked from a mouse down event to resize a column's height for a long string.

Example [Visual Basic]

The following example shows a possible override of the GetPreferredSize method.

[Visual Basic]

Overrides Function GetAutoResizeHeight(ByVal g As UI.System.Drawing.Graphics, ByVal value As object) As Long
   ' Use the MeasureString function to return a SizeF. The function uses
   ' values (Width and xMargin) that have been calculated and stored elsewhere.
   Dim myF As System.Drawing.SizeF
   
   myF = MeasureString(value, Me.Font, Width - 2*XMargin)
   GetAutoResizeHeight = myF.Height
End Function

See Also

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