Aracılığıyla paylaş


DataGridViewCellStyle.Padding Özellik

Tanım

Bir DataGridViewCell kenarıyla içeriği arasındaki boşluğu alır veya ayarlar.

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

Özellik Değeri

bir Padding kenarı ile içeriği arasındaki boşluğu temsil eden bir DataGridViewCell .

Örnekler

Aşağıdaki kod örneği, sahip tarafından çizilmiş satırları içeren bir DataGridView denetimde bu özelliğin kullanımını gösterir. Her satır, normal hücre içeriğinin altındaki satırın tüm genişliğini kapsayan metni görüntüler. Padding özelliği, bu metin için ek alan sağlamak için kullanılır. Örnekte, gereken ek yükseklik adlı CUSTOM_CONTENT_HEIGHTbir sabitte depolanır.

Bu kod örneği daha büyük bir örneğin parçasıdır. Tam örnek için bkz . Nasıl yapılır: Windows Forms DataGridView Denetiminde Satırların Görünümünü Özelleştirme.

// 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

Açıklamalar

özelliğinin Padding ayarlanması, öğesinin düzenleme denetiminin DataGridViewCell çizildiği yeri etkiler. Örneğin , , ve özellikleri için LeftTopdeğeri 10 olan bir DataGridViewTextBoxCellSystem.Windows.Forms.Padding değerine ayarlarsanızPadding, hücrenin içeriği, metin kutusunun kenarlarıyla hücrenin kenarları arasında 10 piksel boşlukla hücrenin ortasına çizilir.BottomRight

Şunlara uygulanır

Ayrıca bkz.