DataGridViewButtonColumn.UseColumnTextForButtonValue Vlastnost

Definice

Získá nebo nastaví hodnotu označující, zda Text je hodnota vlastnosti zobrazena jako text tlačítka pro buňky v tomto sloupci.

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

Hodnota vlastnosti

trueText hodnota vlastnosti je zobrazena na tlačítkách ve sloupci; false pokud FormattedValue je hodnota vlastnosti každé buňky zobrazena na příslušném tlačítku. Výchozí formát je false.

Výjimky

Hodnota CellTemplate vlastnosti je null.

Příklady

Následující příklad kódu ukazuje použití této vlastnosti.

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

Poznámky

Ve výchozím nastavení DataGridViewCell.FormattedValue se buňka tlačítka zobrazuje jako text na tlačítku. Vlastnost UseColumnTextForButtonValue umožňuje buď nastavit text tlačítka pro každou buňku Text , nebo použít hodnotu vlastnosti pro všechny buňky tlačítka.

Získání nebo nastavení této vlastnosti získá nebo nastaví UseColumnTextForButtonValue vlastnost objektu vráceného CellTemplate vlastností . Nastavení této vlastnosti také nastaví UseColumnTextForButtonValue vlastnost každé buňky ve sloupci a aktualizuje zobrazení sloupce. Pokud chcete přepsat zadanou hodnotu pro jednotlivé buňky, nastavte hodnoty buněk po nastavení hodnoty sloupce.

Platí pro

Viz také