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

Dim instance As DataGridView Dim value As Integer value = instance.RowHeadersWidth instance.RowHeadersWidth = value
[LocalizableAttribute(true)] public: property int RowHeadersWidth { int get (); void set (int value); }
/** @property */ public int get_RowHeadersWidth () /** @property */ public void set_RowHeadersWidth (int value)
行ヘッダーを含む列の幅 (ピクセル単位)。既定値は 43 です。


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); } } }

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


DataGridView クラス
DataGridView メンバ
System.Windows.Forms 名前空間
AutoResizeRowHeadersWidth
その他の技術情報
DataGridView コントロール (Windows フォーム)
Weblioに収録されているすべての辞書からDataGridView.RowHeadersWidth プロパティを検索する場合は、下記のリンクをクリックしてください。

- DataGridView.RowHeadersWidth プロパティのページへのリンク