DataGridColumnStyle.GetPreferredHeight(Graphics, Object) DataGridColumnStyle.GetPreferredHeight(Graphics, Object) DataGridColumnStyle.GetPreferredHeight(Graphics, Object) DataGridColumnStyle.GetPreferredHeight(Graphics, Object) Method

정의

파생 클래스에서 재정의된 경우 열을 자동으로 크기 조정하는 데 사용된 높이를 가져옵니다.When overridden in a derived class, gets the height used for automatically resizing columns.

protected public:
 abstract int GetPreferredHeight(System::Drawing::Graphics ^ g, System::Object ^ value);
protected internal abstract int GetPreferredHeight (System.Drawing.Graphics g, object value);
abstract member GetPreferredHeight : System.Drawing.Graphics * obj -> int
Protected Friend MustOverride Function GetPreferredHeight (g As Graphics, value As Object) As Integer

매개 변수

g
Graphics Graphics Graphics Graphics

Graphics 개체입니다.A Graphics object.

value
Object Object Object Object

화면 높이와 너비를 알고자 하는 개체 값입니다.An object value for which you want to know the screen height and width.

반환

셀을 자동으로 크기 조정하는 데 사용된 높이입니다.The height used for auto resizing a cell.

예제

다음 코드 예제에서는 GetPreferredHeight 셀의 높이 반환 하는 방법입니다.The following code example uses the GetPreferredHeight method to return the height of a cell.

public ref class MyGridColumn: public DataGridTextBoxColumn
{
public:
   int GetPrefHeight( Graphics^ g, String^ thisString )
   {
      return this->GetPreferredHeight( g, thisString );
   }

};

public ref class Form1: public Form
{
protected:
   DataGrid^ dataGrid1;

private:
   void GetHeight()
   {
      MyGridColumn^ myGridColumn;
      
      // Get a DataGridColumnStyle of a DataGrid control.
      myGridColumn = dynamic_cast<MyGridColumn^>(dataGrid1->TableStyles[ 0 ]->GridColumnStyles[ "CompanyName" ]);
      
      // Create a Graphics object.
      Graphics^ g = this->CreateGraphics();
      Console::WriteLine( myGridColumn->GetPrefHeight( g, "A string" ) );
   }

};

public class Form1: Form
{
 protected DataGrid dataGrid1;

private void GetHeight(){
    MyGridColumn myGridColumn;
    // Get a DataGridColumnStyle of a DataGrid control.
    myGridColumn = (MyGridColumn) dataGrid1.TableStyles[0].
    GridColumnStyles["CompanyName"];
    // Create a Graphics object.
    Graphics g = this.CreateGraphics();
    Console.WriteLine(myGridColumn.GetPrefHeight(g, "A string"));
 }
}

public class MyGridColumn:DataGridTextBoxColumn{
   public int GetPrefHeight(Graphics g, string thisString){
      return this.GetPreferredHeight(g,thisString);
   }
}
Public Class Form1
    Inherits Form
    Protected dataGrid1 As DataGrid
    

    Private Sub GetHeight()
        Dim myGridColumn As MyGridColumn
        ' Get a DataGridColumnStyle of a DataGrid control.
        myGridColumn = CType(dataGrid1.TableStyles(0). _
        GridColumnStyles("CompanyName"), myGridColumn)
        ' Create a Graphics object.
        Dim g As Graphics = Me.CreateGraphics()
        Console.WriteLine(myGridColumn.GetPrefHeight(g, "A string"))
    End Sub 

End Class 

Public Class MyGridColumn
Inherits DataGridTextBoxColumn
   public Function GetPrefHeight (g As Graphics , _
   thisString As String ) As Integer
      return me.GetPreferredHeight(g,thisString)
   End Function
End Class

설명

GetPreferredSize 일반적으로 마우스 누름 긴 문자열에 대 한 열의 높이 조정 하는 이벤트에서에서 호출 됩니다.The GetPreferredSize will usually be invoked from a mouse down event to resize a column's height for a long string.

적용 대상

추가 정보