Hi,
When my grid is displayed on the screen a row seems to be selected. I have added a context menu to grid and i want the row at which the mouse is pointing out to get selected.
I am using the following code:
private
{
UltraGridRow
UIElement element;
if (e.Button == MouseButtons.Right)
element = ultraGrid1.DisplayLayout.UIElement.ElementFromPoint(e.Location);
row = element.GetContext(typeof(UltraGridRow)) as UltraGridRow;
ultraGrid1.Selected.Rows.Clear();
}
Now, the problem is the row which seemed to be selected earlier is still selected and the new row is also selected. The problem also occurs when I selects a row to edit and then right click on any other row.
Perhaps some code formatting got lost when you pasted it, but it looks like you're clearing the selected rows regardless (though I expect an 'else' was there). Regardless, it sounds like you're confusing the ActiveRow with a selected row, which can generally appear to be the same if you haven't set any appearances to distinguish them. Try calling Activate() on the row when you select it at the same time, or adjust the appearance through something like the grid.DisplayLayout.Override.ActiveRowAppearance.
-Matt
Thanks Matt,
I set Row.Activated propertety to true and got the desired result.