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
i dont know.. but i guess the rows are not being removed that's why when clicking the row is still highlighted (although it's not selected coz i checked the selectedrows collection). there must be another solution but i just gave you the first solution i came up with.
Hi Hady,
It takes a bit more coding than that, because I've hidden columns which should also be hidden from the columnchooser, but it works.I do think it's a bug, don't you?
Thanks!
Roel
try setting the datasource of the grid to null before this.dsData.Rows.Clear().