在我的表单应用程序中,有一个(buttonNEW
)选择NewIndexRow
of 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
不会改变。
问题是什么?
这应该有效:-
int numofRows = dataGridView.rows.count;
dataGridView.CurrentCell = dataGridView.Rows[numofRows - 1].Cells[0];
或者我认为你也可以这样做:-
dataGridView.CurrentCell = dataGridView.Rows[dataGridView.NewRowIndex].Cells[0];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)