DataGridViewCellStyle::Padding Property
Gets or sets the space between the edge of a DataGridViewCell and its content.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Property Value
Type: System.Windows.Forms::PaddingA Padding that represents the space between the edge of a DataGridViewCell and its content.
Setting the Padding property affects where the editing control of the DataGridViewCell is drawn. For example, if you set Padding on a DataGridViewTextBoxCell to a System.Windows.Forms::Padding that has a value of 10 for its Left, Top, Right, and Bottom properties, the content of the cell is drawn in the middle of the cell with a space of 10 pixels between the edges of the text box and the edges of the cell.
The following code example illustrates the use of this property in a DataGridView control that contains owner-drawn rows. Each row displays text that spans the entire width of the row underneath the regular cell content. The Padding property is used to provide the extra space for this text. In the example, the extra height required is stored in a constant called CUSTOM_CONTENT_HEIGHT.
This code example is part of a larger example. For the complete example, see How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control.
Available since 2.0