DataGridTextBoxColumn.GetPreferredHeight(Graphics, Object) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
열 크기를 자동으로 조정하는 데 사용할 높이를 가져옵니다.
protected public:
override int GetPreferredHeight(System::Drawing::Graphics ^ g, System::Object ^ value);
protected internal override int GetPreferredHeight (System.Drawing.Graphics g, object value);
override this.GetPreferredHeight : System.Drawing.Graphics * obj -> int
Protected Friend Overrides Function GetPreferredHeight (g As Graphics, value As Object) As Integer
매개 변수
- value
- Object
그릴 값입니다.
반환
셀 크기를 자동으로 조정할 높이입니다.
예제
다음 예제에서는 열 크기가 자동으로 조정되는 높이를 반환하는 방법을 사용합니다 GetPreferredHeight .
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 );
}
};
public class Form1: 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 = (MyGridColumn)
dataGrid1.TableStyles[0].GridColumnStyles[1];
string myVal;
myVal = "A long string value";
gridPreferredHeight= myTextColumn.GetPrefHeight(g, myVal);
Console.WriteLine(gridPreferredHeight);
}
}
public class MyGridColumn:DataGridTextBoxColumn{
public int GetPrefHeight(Graphics g, string val){
return this.GetPreferredHeight(g, val);
}
}
Public Class Form1
Inherits Form
Protected dataGrid1 As DataGrid
Private Sub GetPreferredHeight()
Dim g As Graphics
g = Me.CreateGraphics()
Dim gridPreferredHeight As Integer
Dim myTextColumn As MyGridColumn
' Assuming column 1 of a DataGrid control is a
' DataGridTextBoxColumn.
myTextColumn = CType(dataGrid1.TableStyles(0). _
GridColumnStyles(1), MyGridColumn)
Dim myVal As String
myVal = "A long string value"
gridPreferredHeight = myTextColumn.GetPrefHeight _
(g, myVal)
Console.WriteLine(gridPreferredHeight)
End Sub
End Class
Public Class MyGridColumn
Inherits DataGridTextBoxColumn
public Function GetPrefHeight(g As Graphics , val As string) _
As Integer
return me.GetPreferredHeight(g, val)
End Function
End Class