DataGridViewCellStyle.Padding プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As DataGridViewCellStyle Dim value As Padding value = instance.Padding instance.Padding = value
/** @property */ public Padding get_Padding () /** @property */ public void set_Padding (Padding value)
DataGridViewCell の端とその内容との間隔を表す Padding。

Padding プロパティを設定すると、DataGridViewCell の編集コントロールを描画する位置が影響を受けます。たとえば、Left、Top、Right、および Bottom の各プロパティの値が 10 に設定されている System.Windows.Forms.Padding を DataGridViewTextBoxCell の Padding に設定すると、セルの内容がセルの中央に描画され、テキスト ボックスの端とセルの端との間隔が 10 ピクセルになります。

オーナー描画列を含む DataGridView コントロールで、このプロパティを使用するコード例を次に示します。各行には、行の幅全体にわたるテキストが、通常のセルの内容に隠れて表示されています。Padding プロパティを使用して、このテキストを表示するための追加の領域を作成します。この例では、追加する必要のある高さが CUSTOM_CONTENT_HEIGHT という定数に格納されます。
ここに示すコード例は、より長い例の一部です。コード例全体については、「方法 : Windows フォームの DataGridView コントロールの行の外観をカスタマイズする」を参照してください。
' 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
// 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;

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- DataGridViewCellStyle.Padding プロパティのページへのリンク