DataGridViewButtonCell.UseColumnTextForButtonValue 属性

定义

获取或设置一个值,此值指示所属列的文本是否出现在由单元格显示的按钮上。Gets or sets a value indicating whether the owning column's text will appear on the button displayed by the cell.

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

属性值

Boolean

如果 Value 属性的值能自动匹配所属列 Text 属性的值,则为 true;否则为 falsetrue if the value of the Value property will automatically match the value of the Text property of the owning column; otherwise, false. 默认值为 falseThe default is false.

示例

下面的代码示例演示如何使用此成员。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);
}
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

注解

FormattedValue按钮单元格的显示为按钮上的文本。The FormattedValue of a button cell is displayed as text on the button. UseColumnTextForButtonValue属性允许您设置每个单元的按钮文本,或者使用 Text 所有按钮单元的父列的属性值。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.

设置 UseColumnTextForButtonValue 所属列的属性还会设置 UseColumnTextForButtonValue 列中每个单元格的属性,并刷新列显示。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.

适用于

另请参阅