Hi,
I am wondering is there any properties if user press right click on datagrid then row become active.
Or I have to write code for that?
I don't know if there is a way to do it without code. If there isn't, here is some code to do it:
Private Sub grid_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles grid.MouseDown If e.Button = Windows.Forms.MouseButtons.Right Then Dim mousePoint As Point = New Point(e.X, e.Y) 'get the user interface element from the location of the mouse click Dim element As UIElement = gridEquipment.DisplayLayout.UIElement.ElementFromPoint(mousePoint) Dim row As UltraGridRow = Nothing 'see if that element is an ultragridrow row = CType(element.GetContext(GetType(UltraGridRow)), UltraGridRow) If row IsNot Nothing Then 'select the row first row.Selected = True End If End IfEnd Sub
Thanks Dear. My problem has been solved
ugVendorList.Selected.Rows.Clear();
I used this code to select the row on right click. However, I only want one row selected at a time. When I right click, how can I select that row and unselect any previously selected row?
{
Infragistics.Win.UIElement element;
element = ugVendorList.DisplayLayout.UIElement.ElementFromPoint(e.Location);
row = element.GetContext(typeof(Infragistics.Win.UltraWinGrid.UltraGridRow)) as Infragistics.Win.UltraWinGrid.UltraGridRow;
}
Editing to add: I want to allow multiple selections by using Ctrl+left click,etc, but when right clicking I only want to select the current row and deselect everything else.