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
975
Active row on right click
posted

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?

Parents
No Data
Reply
  • 733
    Verified Answer
    posted

    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 If
    End Sub

Children