DataGridViewCell.Style プロパティ

定義

セルのスタイルを取得または設定します。

public:
 property System::Windows::Forms::DataGridViewCellStyle ^ Style { System::Windows::Forms::DataGridViewCellStyle ^ get(); void set(System::Windows::Forms::DataGridViewCellStyle ^ value); };
[System.ComponentModel.Browsable(true)]
public System.Windows.Forms.DataGridViewCellStyle Style { get; set; }
[<System.ComponentModel.Browsable(true)>]
member this.Style : System.Windows.Forms.DataGridViewCellStyle with get, set
Public Property Style As DataGridViewCellStyle

プロパティ値

DataGridViewCellStyle

セルに関連付けられたスタイル。

属性

次のコード例は、プロパティを使用 Style してセルの背景色を取得する方法を示しています。 この例は、クラスに対して提供されるより大きなコード例の DataGridViewColumn 一部です。

void CustomizeCellsInThirdColumn()
{
   int thirdColumn = 2;
   DataGridViewColumn^ column = dataGridView->Columns[ thirdColumn ];
   DataGridViewCell^ cell = gcnew DataGridViewTextBoxCell;
   cell->Style->BackColor = Color::Wheat;
   column->CellTemplate = cell;
}
private void CustomizeCellsInThirdColumn()
{
    int thirdColumn = 2;
    DataGridViewColumn column =
        dataGridView.Columns[thirdColumn];
    DataGridViewCell cell = new DataGridViewTextBoxCell();

    cell.Style.BackColor = Color.Wheat;
    column.CellTemplate = cell;
}
Private Sub CustomizeCellsInThirdColumn()

    Dim thirdColumn As Integer = 2
    Dim column As DataGridViewColumn = _
        dataGridView.Columns(thirdColumn)
    Dim cell As DataGridViewCell = _
        New DataGridViewTextBoxCell()

    cell.Style.BackColor = Color.Wheat
    column.CellTemplate = cell
End Sub

注釈

コントロールは DataGridView 、セル プロパティによって示されるスタイルを使用してセル InheritedStyle を表示します。このスタイルは、型の他のプロパティからスタイルを継承します DataGridViewCellStyle。 プロパティで Style 指定されたスタイルは、他のすべてのセル スタイル プロパティで指定されたスタイルをオーバーライドしますが、セルの外観に影響するすべてのスタイルを必ずしも示すわけではありません。

詳細については、「Windows フォーム DataGridView コントロールでのセルのスタイル」を参照してください。

適用対象

こちらもご覧ください