Export (0) Print
Expand All

DataGridViewButtonCell.UseColumnTextForButtonValue Property

Gets or sets a value indicating whether the owning column's text will appear on the button displayed by the cell.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public bool UseColumnTextForButtonValue { get; set; }

Property Value

Type: System.Boolean
true if the value of the Value property will automatically match the value of the DataGridViewButtonColumn.Text property of the owning column; otherwise, false. The default is false.

The FormattedValue of a button cell is displayed as text on the button. The UseColumnTextForButtonValue property allows you to either set the button text for each cell, or to use the Text property value of the parent column for all of the button cells.

Setting the UseColumnTextForButtonValue property of the owning column also sets the UseColumnTextForButtonValue property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value.

The following code example demonstrates the use of this member.

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);
}

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft