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

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

DataGridView.RowHeadersWidth プロパティ

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

ヘッダーを含む列の幅をピクセル単位取得または設定します

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

<LocalizableAttribute(True)> _
Public Property RowHeadersWidth As
 Integer
Dim instance As DataGridView
Dim value As Integer

value = instance.RowHeadersWidth

instance.RowHeadersWidth = value
[LocalizableAttribute(true)] 
public int RowHeadersWidth { get;
 set; }
[LocalizableAttribute(true)] 
public:
property int RowHeadersWidth {
    int get ();
    void set (int value);
}
/** @property */
public int get_RowHeadersWidth ()

/** @property */
public void set_RowHeadersWidth (int
 value)
public function get RowHeadersWidth
 () : int

public function set RowHeadersWidth
 (value : int)

プロパティ
ヘッダーを含む列の幅 (ピクセル単位)。既定値43 です。

例外例外
例外種類条件

ArgumentOutOfRangeException

このプロパティ設定時に指定された値が 4 ピクセル (最小の幅) より小さいか、32768 ピクセル (最大の幅) を超えてます。

解説解説

RowHeadersWidth プロパティ使用すると、行ヘッダー列のサイズ指定された幅に変更できます。行ヘッダー セル内容合わせてこの列の幅を調整するには、AutoResizeRowHeadersWidth メソッド使用します

使用例使用例

行を描画するシナリオRowHeadersWidth プロパティ使用する方法コード例次に示します。この例では、このプロパティの値を使用してカスタム背景描画される境界線計算されます。

ここに示すコードは、「方法 : Windows フォームの DataGridView コントロールの行の外観カスタマイズする」で取り上げられているコード一部です。

' Paints the custom selection background for selected rows.
Sub dataGridView1_RowPrePaint(ByVal sender
 As Object, _
    ByVal e As DataGridViewRowPrePaintEventArgs)
 _
    Handles dataGridView1.RowPrePaint

    ' Do not automatically paint the focus rectangle.
    e.PaintParts = e.PaintParts And Not DataGridViewPaintParts.Focus

    ' Determine whether the cell should be painted with the 
    ' custom selection background.
    If (e.State And DataGridViewElementStates.Selected)
 = _
        DataGridViewElementStates.Selected Then

        ' Calculate the bounds of the row.
        Dim rowBounds As New
 Rectangle( _
            Me.dataGridView1.RowHeadersWidth, e.RowBounds.Top,
 _
            Me.dataGridView1.Columns.GetColumnsWidth( _
            DataGridViewElementStates.Visible) - _
            Me.dataGridView1.HorizontalScrollingOffset + 1, _
            e.RowBounds.Height)

        ' Paint the custom selection background.
        Dim backbrush As New
 _
            System.Drawing.Drawing2D.LinearGradientBrush(rowBounds, _
            Me.dataGridView1.DefaultCellStyle.SelectionBackColor,
 _
            e.InheritedRowStyle.ForeColor, _
            System.Drawing.Drawing2D.LinearGradientMode.Horizontal)
        Try
            e.Graphics.FillRectangle(backbrush, rowBounds)
        Finally
            backbrush.Dispose()
        End Try
    End If

End Sub 'dataGridView1_RowPrePaint
// Paints the custom selection background for selected rows.
void dataGridView1_RowPrePaint(object sender,
        DataGridViewRowPrePaintEventArgs e)
{
    // Do not automatically paint the focus rectangle.
    e.PaintParts &= ~DataGridViewPaintParts.Focus;

    // Determine whether the cell should be painted
    // with the custom selection background.
    if ((e.State & DataGridViewElementStates.Selected) ==
                DataGridViewElementStates.Selected)
    {
        // Calculate the bounds of the row.
        Rectangle rowBounds = new Rectangle(
            this.dataGridView1.RowHeadersWidth, e.RowBounds.Top
,
            this.dataGridView1.Columns.GetColumnsWidth(
                DataGridViewElementStates.Visible) -
            this.dataGridView1.HorizontalScrollingOffset + 1,
            e.RowBounds.Height);

        // Paint the custom selection background.
        using (Brush backbrush =
            new System.Drawing.Drawing2D.LinearGradientBrush(rowBounds
,
                this.dataGridView1.DefaultCellStyle.SelectionBackColor
,
                e.InheritedRowStyle.ForeColor,
                System.Drawing.Drawing2D.LinearGradientMode.Horizontal))
        {
            e.Graphics.FillRectangle(backbrush, rowBounds);
        }
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からDataGridView.RowHeadersWidth プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からDataGridView.RowHeadersWidth プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からDataGridView.RowHeadersWidth プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

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

   

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



DataGridView.RowHeadersWidth プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS