DataGridViewButtonColumn.UseColumnTextForButtonValue プロパティ

定義

Text プロパティの値が、この列に含まれるセルのボタン テキストとして表示されるかどうかを示す値を取得または設定します。

public:
 property bool UseColumnTextForButtonValue { bool get(); void set(bool value); };
public bool UseColumnTextForButtonValue { get; set; }
member this.UseColumnTextForButtonValue : bool with get, set
Public Property UseColumnTextForButtonValue As Boolean

プロパティ値

Text プロパティの値が列内のボタンに表示される場合は true。各セルの FormattedValue プロパティの値がボタンに表示される場合は false。 既定値は、false です。

例外

CellTemplate プロパティの値が null です。

次のコード例では、このプロパティの使用方法を示します。

private void CreateUnboundButtonColumn()
{
    // Initialize the button column.
    DataGridViewButtonColumn buttonColumn =
        new DataGridViewButtonColumn();
    buttonColumn.Name = "Details";
    buttonColumn.HeaderText = "Details";
    buttonColumn.Text = "View Details";

    // Use the Text property for the button text for all cells rather
    // than using each cell's value as the text for its own button.
    buttonColumn.UseColumnTextForButtonValue = true;

    // Add the button column to the control.
    dataGridView1.Columns.Insert(0, buttonColumn);
}
Private Sub CreateUnboundButtonColumn()

    ' Initialize the button column.
    Dim buttonColumn As New DataGridViewButtonColumn

    With buttonColumn
        .HeaderText = "Details"
        .Name = "Details"
        .Text = "View Details"

        ' Use the Text property for the button text for all cells rather
        ' than using each cell's value as the text for its own button.
        .UseColumnTextForButtonValue = True
    End With

    ' Add the button column to the control.
    dataGridView1.Columns.Insert(0, buttonColumn)

End Sub

注釈

既定では、ボタン セルの が DataGridViewCell.FormattedValue ボタンのテキストとして表示されます。 UseColumnTextForButtonValueプロパティを使用すると、各セルのボタン テキストを設定したり、すべてのボタン セルにTextプロパティ値を使用したりできます。

このプロパティを取得または設定すると、 UseColumnTextForButtonValue プロパティによって返されるオブジェクトのプロパティを CellTemplate 取得または設定します。 このプロパティを設定すると、列内のすべてのセルの プロパティも設定 UseColumnTextForButtonValue され、列の表示が更新されます。 個々のセルに対して指定した値をオーバーライドするには、列の値を設定した後にセル値を設定します。

適用対象

こちらもご覧ください