我有一个DataGridView类型为 的列DataGridViewButtonColumn。
我想在按钮上放一段文字。我已经尝试在“编辑列”选项中将文本放入“文本”属性中。我什至尝试过 swtteing UseColumnTextForButtonValue = true。
我找不到让它工作的方法。
是否要将 DataGridViewButtonColumn Text 绑定到 DataGridView 的 DataSource?如果是这样,则通过“编辑列”选项为列设置 DataPropertyName。
否则你可以尝试使用 DataGridView 的 CellFormatting 事件:
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.ColumnIndex == 0)
{
e.Value = "some value";
}
}
Run Code Online (Sandbox Code Playgroud)