Hi,
I have a grid for which I've set DisplayLayout.Override.CellClickAction to RowSelect.
I use the DoubleClickRow event to clear the data of the grid, fill the grid with data and then I activate/select the first row:
private void grdData_DoubleClickRow(object sender, Infragistics.Win.UltraWinGrid.DoubleClickRowEventArgs e) { this.dsData.Rows.Clear(); for (int i = 0; i < 10; i++) { UltraDataRow rootRow = this.dsData.Rows.Add(); rootRow["Column 0"] = "1"; rootRow["Column 1"] = "1"; } this.grdData.Rows[0].Activate(); this.grdData.Rows[0].Selected = true; this.grdData.Selected.Rows.Clear(); }
The problem is that the originally selected row gets selected again after grdData_DoubleClickRow() has finished. So I end up with the first row being selected and activated, but also with the originally selected row as selected. So the end result is that two rows are selected instead of one.
When I select a row and use the KeyDown event (using the F5 key in my example), I don't have this issue:
private void grdData_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.F5) { this.dsData.Rows.Clear(); for (int i = 0; i < 10; i++) { UltraDataRow rootRow = this.dsData.Rows.Add(); rootRow["Column 0"] = "1"; rootRow["Column 1"] = "1"; } this.grdData.Rows[0].Activate(); this.grdData.Rows[0].Selected = true; this.grdData.Selected.Rows.Clear(); } }
What could be the problem here?
regards,
Roel van Bueren
May be one possible solution is to change your code like this:
private void grdData_DoubleClickRow(object sender, Infragistics.Win.UltraWinGrid.DoubleClickRowEventArgs e) { this.dsData.Rows.Clear(); for (int i = 0; i < 10; i++) { UltraDataRow rootRow = this.dsData.Rows.Add(); rootRow["Column 0"] = "1"; rootRow["Column 1"] = "1"; } this.grdData.DataSource = null; this.grdData.DataSource = dsData; }
for (int i = 0; i < 10; i++) { UltraDataRow rootRow = this.dsData.Rows.Add(); rootRow["Column 0"] = "1"; rootRow["Column 1"] = "1"; } this.grdData.DataSource = null; this.grdData.DataSource = dsData; }
Please check it and send me a feedback.Regards
Georgi"] this.grdData.DataSource = null;this.grdData.DataSource = dsData;
this.grdData.DataSource = null;this.grdData.DataSource = dsData;
Yes. This works, but that's something I already tried based on Hadi's feedback.