【发布时间】:2012-11-20 07:25:24
【问题描述】:
在我的表单应用程序中,有一个 (buttonNEW) 选择了 NewIndexRow 的 DataGridView,我想使用此按钮更改 datagridview 的索引。
private void buttonNew_Click(object sender, EventArgs e)
{
if (dataGridView.CurrentRow.Index!=dataGridView.NewRowIndex)
{
dataGridView.ClearSelection();
dataGridView.Rows[dataGridView.NewRowIndex].Selected = true;
label1.Text = dataGridView.CurrentRow.Index.ToString();
}
}
但点击按钮后DataGridView 的索引并没有改变。
有什么问题?
【问题讨论】:
-
你确定 NewRowIndex 有值吗?
-
NewRowIndex 是空行。我想用户点击 buttonNEW 并选择最后一行输入数据
标签: c# winforms datagridview