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
945
Clearing Previously-Selected Rows On Mouse Click
posted

I have an UltraGrid control on a form, and the form has a context menu which the grid references as its context menu strip.  When you invoke the context menu (right-click), I've noticed the underlying row (I have full row selection enabled) does not become selected and/or focused.  So, I added the event handler below to try to accomplish this.  When I left-click a row and then right click another row, there are two rows selected.  My grid is set only to have one selected row at a time, but for some reason when the event fires, it still results in multiple rows being selected.  The message box is in place to demonstrate that the program thinks there is only one row selected, but the UI shows two rows.  Is there something I'm doing wrong?

 

Private Sub LogDataUltraGrid_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles LogDataUltraGrid.MouseDown
            'get the cell that was clicked..
            Dim objCell As UltraGridCell = _
                Me.LogDataUltraGrid.DisplayLayout.UIElement.LastElementEntered.GetContext(GetType(UltraGridCell))

            If Not objCell Is Nothing Then
                'remove the previous selection if there was one...
                If Me.LogDataUltraGrid.Selected.Rows.Count > 0 Then Me.LogDataUltraGrid.Selected.Rows(0).Selected = False

                objCell.Row.Selected = True
                MsgBox(Me.LogDataUltraGrid.Selected.Rows.Count)
            End If
    End Sub

 

 

Parents Reply Children