DataGridViewCellStyle.Padding 속성

정의

DataGridViewCell의 가장자리와 내용 사이의 간격을 가져오거나 설정합니다.

public:
 property System::Windows::Forms::Padding Padding { System::Windows::Forms::Padding get(); void set(System::Windows::Forms::Padding value); };
public System.Windows.Forms.Padding Padding { get; set; }
member this.Padding : System.Windows.Forms.Padding with get, set
Public Property Padding As Padding

속성 값

Padding

Padding의 가장자리와 내용 사이의 간격을 나타내는 DataGridViewCell입니다.

예제

다음 코드 예제에서는 소유자가 그린 행을 DataGridView 포함 하는 컨트롤에서이 속성을 사용 하는 방법을 보여 줍니다. 각 행은 일반 셀 내용 아래 행의 전체 너비에 걸쳐 있는 텍스트를 표시합니다. 이 Padding 속성은 이 텍스트에 대한 추가 공간을 제공하는 데 사용됩니다. 이 예제에서 필요한 추가 높이가 상수인 CUSTOM_CONTENT_HEIGHT에 저장됩니다.

이 코드 예제는 더 큰 예제의 일부입니다. 전체 예제는 방법: Windows Forms DataGridView 컨트롤에서 행 모양 사용자 지정을 참조하세요.

// Set a cell padding to provide space for the top of the focus 
// rectangle and for the content that spans multiple columns. 
Padding newPadding = new Padding(0, 1, 0, CUSTOM_CONTENT_HEIGHT);
this.dataGridView1.RowTemplate.DefaultCellStyle.Padding = newPadding;

// Set the selection background color to transparent so 
// the cell won't paint over the custom selection background.
this.dataGridView1.RowTemplate.DefaultCellStyle.SelectionBackColor =
    Color.Transparent;

// Set the row height to accommodate the content that 
// spans multiple columns.
this.dataGridView1.RowTemplate.Height += CUSTOM_CONTENT_HEIGHT;
' Set a cell padding to provide space for the top of the focus 
' rectangle and for the content that spans multiple columns. 
Dim newPadding As New Padding(0, 1, 0, CUSTOM_CONTENT_HEIGHT)
Me.dataGridView1.RowTemplate.DefaultCellStyle.Padding = newPadding

' Set the selection background color to transparent so 
' the cell won't paint over the custom selection background.
Me.dataGridView1.RowTemplate.DefaultCellStyle.SelectionBackColor = _
    Color.Transparent

' Set the row height to accommodate the normal cell content and the 
' content that spans multiple columns.
Me.dataGridView1.RowTemplate.Height += CUSTOM_CONTENT_HEIGHT

설명

속성을 설정하면 Padding 편집 컨트롤 DataGridViewCell 이 그려지는 위치에 영향을 줍니다. 예를 들어 해당 , TopBottom Right속성에 DataGridViewTextBoxCell System.Windows.Forms.Padding 대해 Left값이 10인 값으로 설정 Padding 하면 셀의 내용이 텍스트 상자의 가장자리와 셀 가장자리 사이에 10픽셀의 공백이 있는 셀 중간에 그려집니다.

적용 대상

추가 정보