Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
25
Problem in UltraGird Row selection
posted

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

 

 

void ultraGrid1_MouseDown(object sender, MouseEventArgs e)

{

UltraGridRow

 

 

row;  

UIElement element;

 if (e.Button == MouseButtons.Right)

element = ultraGrid1.DisplayLayout.UIElement.ElementFromPoint(e.Location);

row = element.GetContext(typeof(UltraGridRow)) as UltraGridRow;

 

if(row != null && row.IsDataRow) row.Selected = true;

{

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.

Parents
  • 37774
    Verified Answer
    posted

    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

Reply Children
No Data