我用了两个dataGrid来显示数据库中的同一个表的不同字段的记录,现在想搞成当点击dataGrid1的某一行时,dataGrid2的相应一行也被选中了,但是我在dataGrid1的CurrentCellChanged事件中写
this.dataGrid1.Select(this.dataGrid1.CurrentRowIndex);
this.dataGrid2.Select(this.dataGrid2.CurrentRowIndex);这样做好像不行啊,当选中dataGrid1的第一条记录时dataGrid2也选中了第一条记录,但是当选中dataGrid1的第二条记录的时候,dataGrid2也选中了第二条,问题就是出在这里,dataGrid2的第一条记录还是显示为选定的,大家有什么办法可以去掉第一条记录的选择的?????
this.dataGrid1.Select(this.dataGrid1.CurrentRowIndex);
this.dataGrid2.Select(this.dataGrid2.CurrentRowIndex);这样做好像不行啊,当选中dataGrid1的第一条记录时dataGrid2也选中了第一条记录,但是当选中dataGrid1的第二条记录的时候,dataGrid2也选中了第二条,问题就是出在这里,dataGrid2的第一条记录还是显示为选定的,大家有什么办法可以去掉第一条记录的选择的?????
dataGrid2.selectIndex = this.dataGrid1.CurrentRowIndex;
dataGrid2.SelectedIndex = -1;
dataGrid2.selectedIndex = this.dataGrid1.CurrentRowIndex;
this.dataGrid1.Select(index);
this.dataGrid2.CurrentRowIndex = index;