There are two DataGrid on a WinForm, when one of them is selected, how to make another currentrowindex become empty?

xiaoxiao2021-03-06  75

What you said is that if you set it to currentrowindex = -1; then pressing it to make an error, so you can only deselect the selected line, that is, using unselect () method

Write the following code implementation in the DataGrid Leave event:

Private void DataGrid1_leave (Object Sender, System.EventArgs E) {this.dataGrid1.unselect (this.DataGrid1.currentcell.rownumber);}

private void dataGrid2_Leave (object sender, System.EventArgs e) {this.dataGrid2.UnSelect (this.dataGrid2.CurrentCell.RowNumber);} If you want to return to when dataGrid1 from dataGrid2 time, dataGrid1 was originally selected display line so , can be resolved private int dgNum1 = 0private void dataGrid1_Leave (object sender, System.EventArgs e) {this.dgNum1 = this.dataGrid1.CurrentCell.RowNumber; this.dataGrid1.UnSelect (this.dgNum1);}

Private void DataGrid1_enter (Object Sender, System.EventArgs E) {this.dataGrid1.select (this.dgnum1);}

转载请注明原文地址:https://www.9cbs.com/read-93292.html

New Post(0)