DataGridTextBoxColumn::GetPreferredHeight Method (Graphics^, Object^)
.NET Framework (current version)
Gets the height to be used in for automatically resizing columns.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Parameters
- g
-
Type:
System.Drawing::Graphics^
A Graphics object used to draw shapes on the screen.
- value
-
Type:
System::Object^
The value to draw.
The following example uses the GetPreferredHeight to return the height a column is automatically resized to.
public ref class MyGridColumn: public DataGridTextBoxColumn { public: int GetPrefHeight( Graphics^ g, String^ val ) { return this->GetPreferredHeight( g, val ); } }; public ref class Form1: public Form { protected: DataGrid^ dataGrid1; private: void GetPreferredHeight() { Graphics^ g; g = this->CreateGraphics(); int gridPreferredHeight; MyGridColumn^ myTextColumn; // Assuming column 1 of a DataGrid control is a // DataGridTextBoxColumn. myTextColumn = dynamic_cast<MyGridColumn^>(dataGrid1->TableStyles[ 0 ]->GridColumnStyles[ 1 ]); String^ myVal; myVal = "A long string value"; gridPreferredHeight = myTextColumn->GetPrefHeight( g, myVal ); Console::WriteLine( gridPreferredHeight ); } };
.NET Framework
Available since 1.1
Available since 1.1
Show: