繁体   English   中英

C# DataGridView Row 添加dataGridView 按钮文字不改变

[英]C# DataGridView Row add dataGridView button text not change

我在 winform 中读取 xml 文件并在 DataGridView 中显示数据 在 xml 中读取的 DataGridView 有一个按钮,单击按钮时,按钮的文本会更改。

DataGridViewButtonCell btnStart = null;
btnStart = (DataGridViewButtonCell)(DataGridView.Rows[e.RowIndex].Cells[0]);
var btnType = btnStart.Value.ToString();
btnStart.UseColumnTextForButtonValue = false;

在此结果中,我尝试重新读取 XML 和 append ROW

DataGridView.DataSource = dataSet.Tables[0];

有没有办法在不更改显示的 DataGridView 中的按钮文本的情况下将 ADD 添加到 DataGridView?

这行代码: DataGridView.DataSource = dataSet.Tables[0];

不读取一行,它重置整个DataGridView ,这就是按钮更改的原因。 如果你想 append 一行,然后向DataGridView显示的表添加一行,不要替换整个东西。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM