DataGridViewButtonCell.UseColumnTextForButtonValue 属性

定义

获取或设置一个值,此值指示所属列的文本是否出现在由单元格显示的按钮上。

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;否则为 false。 默认值为 false

示例

下面的代码示例演示了此成员的使用。

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按钮单元格显示为按钮上的文本。 该 UseColumnTextForButtonValue 属性允许设置每个单元格的按钮文本,或者对所有按钮单元格使用 Text 父列的属性值。

UseColumnTextForButtonValue设置拥有列的属性还会设置UseColumnTextForButtonValue列中每个单元格的属性并刷新列显示。 若要替代单个单元格的指定值,请设置列值后设置单元格值。

适用于

另请参阅