在我的WinForms项目中,我有一个Form
和DataGridView
。当应用程序加载时,DataGridView
充满了数据。在我的DataGridView
中,SelectionMode
设置为FullFowSelect
。DataGridView中的行选择
问题1:当加载Form
时,我怎样才能使它在DataGridView
中没有被选中?
问题2:而初始加载后,我怎么可以设定一个Button
在DataGridView
突出显示特定行(例如,第5行)?
在我的WinForms项目中,我有一个Form
和DataGridView
。当应用程序加载时,DataGridView
充满了数据。在我的DataGridView
中,SelectionMode
设置为FullFowSelect
。DataGridView中的行选择
问题1:当加载Form
时,我怎样才能使它在DataGridView
中没有被选中?
问题2:而初始加载后,我怎么可以设定一个Button
在DataGridView
突出显示特定行(例如,第5行)?
datagridview.Rows[index].Selected = true;
你的情况来选择第五行
datagridview.Rows[4].Selected = true;
我相信你应该设置CurrentCell为DataGridView的
因此,对于你的情况下第五行应该是
dataGridView1.CurrentCell = dataGridView1[0, 4];
选择模式是fullrowselect,他想要选择背景颜色到一行而不是一个单元格 – Marshal 2011-04-05 10:47:52
@Niraj:是的,上面的代码是做这个部分的,该行是根据需要选择的(你是否尝试过你的解决方案并不适合我) – V4Vendetta 2011-04-05 10:52:37