Bagikan melalui


DataGridViewButtonCell.UseColumnTextForButtonValue Properti

Definisi

Mendapatkan atau mengatur nilai yang menunjukkan apakah teks kolom pemilik akan muncul pada tombol yang ditampilkan oleh sel.

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

Nilai Properti

true jika nilai Value properti akan secara otomatis cocok dengan nilai Text properti kolom pemilik; jika tidak, false. Defaultnya adalah false.

Contoh

Contoh kode berikut menunjukkan penggunaan anggota ini.

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

Keterangan

Sel FormattedValue tombol ditampilkan sebagai teks pada tombol. Properti UseColumnTextForButtonValue memungkinkan Anda mengatur teks tombol untuk setiap sel, atau menggunakan Text nilai properti kolom induk untuk semua sel tombol.

UseColumnTextForButtonValue Mengatur properti kolom pemilik juga mengatur UseColumnTextForButtonValue properti setiap sel di kolom dan me-refresh tampilan kolom. Untuk mengganti nilai yang ditentukan untuk sel individual, atur nilai sel setelah Anda mengatur nilai kolom.

Berlaku untuk

Lihat juga