DataGridViewCellStyle.Padding プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataGridViewCellStyle.Padding プロパティの意味・解説 

DataGridViewCellStyle.Padding プロパティ

メモ : このプロパティは、.NET Framework version 2.0 で新しく追加されたものです。

DataGridViewCell の端とその内容との間隔を取得または設定します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

解説解説

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;
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

DataGridViewCellStyle.Padding プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DataGridViewCellStyle.Padding プロパティのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS