I'm having problems with UltraGrid again.
Let's say we have a form with an UltraGrid on it. The grid is databound to a generic BindingList. User is by design not able to edit/add/delete. User can select only one row at time (no multiselect).
The grid is accompanied by "Move Next" and "Move Previous" buttons.. I want to be able to change the currently selected row.
I thought I could acheive this using BindingSource.MoveNext and MovePrevious methods. Partially. The selection changes indeed. Unfortunately, the previously selected item (using either mouse click or keyboard) stays selected (visually).
Similar behaviour can be observed when a user clicks a row, holds the LMB, and moves the cursor over any other row. When the LMB is released UltraGrid shows that 2 rows are selected, instead of only one.
Thanks. That did the trick :)
Hello ,
I have noticed that in your sample you have set ActiveRowAppearance, so active row has the same color as selected row. Calling MoveNext of the binding source, moves to the next item in the list, which performs UltraGrid to change its Active row. When you click with mouse over a UltraGrid’s cells, it causing selection of the row on which this cell belongs (its performs UltraGrid to color the selected row), in this case now you have active row, which is determine from the binding manager and it is colored based on the appearance which you have set for ActiveRowAppearance, and selected row, this one on which you were clicked and it is not activated. In this case active row and selected row are two different objects. So what you could do in your case is to handled BeforRowActivate event and to put the following code:
e.Row.Selected = true;
In order to achieve active and selected row to be the same row.
Please let me know if you have any further questions
Well previously it was set to RowSelect and the problem was still there. Calling anything except MoveNext()/MovePrevious() is unacceptable for me. Control is databound and should fully rely on the BindingSource. When I'm changing the current item, UltraGrid should highlight only this item, not any other.
Thank you for the provided sample. I have had tests it with Infragistics 11.2 service release 2050 (which is the latest available service release ), and I have noticed that there is two selected cell at time, when you click with mouse and then click on button1, but it is because you have set CellClickAction to CellSelect. If you what to keep the value of this property and to avoid this behavior you should clear selected cells collection (ultraGrid1.Selected.Cells.Clear();) before calling MoveNext()
Please let me know if you have any further questions.