DataGridViewButtonCell.FlatStyle 属性

定义

获取或设置确定按钮外观的样式。

public:
 property System::Windows::Forms::FlatStyle FlatStyle { System::Windows::Forms::FlatStyle get(); void set(System::Windows::Forms::FlatStyle value); };
public System.Windows.Forms.FlatStyle FlatStyle { get; set; }
member this.FlatStyle : System.Windows.Forms.FlatStyle with get, set
Public Property FlatStyle As FlatStyle

属性值

FlatStyle 值之一。

例外

当设置此属性时,指定的值不是有效的 FlatStyle 值。

示例

下面的代码示例演示如何使用 DataGridViewButtonColumn.FlatStyle 属性,该属性类似于此属性。 此示例是类概述主题中提供的更大示例的 DataGridViewComboBoxColumn 一部分。

private:
    void AddButtonColumn()
    {
        DataGridViewButtonColumn^ buttons = gcnew DataGridViewButtonColumn();
        {
            buttons->HeaderText = "Sales";
            buttons->Text = "Sales";
            buttons->UseColumnTextForButtonValue = true;
            buttons->AutoSizeMode =
                DataGridViewAutoSizeColumnMode::AllCells;
            buttons->FlatStyle = FlatStyle::Standard;
            buttons->CellTemplate->Style->BackColor = Color::Honeydew;
            buttons->DisplayIndex = 0;
        }

        DataGridView1->Columns->Add(buttons);

    }
private void AddButtonColumn()
{
    DataGridViewButtonColumn buttons = new DataGridViewButtonColumn();
    {
        buttons.HeaderText = "Sales";
        buttons.Text = "Sales";
        buttons.UseColumnTextForButtonValue = true;
        buttons.AutoSizeMode =
            DataGridViewAutoSizeColumnMode.AllCells;
        buttons.FlatStyle = FlatStyle.Standard;
        buttons.CellTemplate.Style.BackColor = Color.Honeydew;
        buttons.DisplayIndex = 0;
    }

    DataGridView1.Columns.Add(buttons);
}
Private Sub AddButtonColumn()
    Dim buttons As New DataGridViewButtonColumn()
    With buttons
        .HeaderText = "Sales"
        .Text = "Sales"
        .UseColumnTextForButtonValue = True
        .AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells
        .FlatStyle = FlatStyle.Standard
        .CellTemplate.Style.BackColor = Color.Honeydew
        .DisplayIndex = 0
    End With

    DataGridView1.Columns.Add(buttons)

End Sub

注解

FlatStyle设置所属列的 属性还会设置FlatStyle列中每个单元格的 属性,并刷新列显示。 若要替代单个单元格的指定值,请在设置列值后设置单元格值。

适用于

另请参阅