Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Right Click Headaches 2

Status
Not open for further replies.

jojo11

Programmer
Feb 2, 2003
189
0
0
US
I want to integrate the right mouse button into my application. I have the concept down for bringing up the popup menu to give the user those options, but I have an issue that is common throughout this integration. When you right click, the selection is not actually made, only the popup menu comes up. FOr example, on my Infragistics SSDBGrid control, when the user right clicks on the grid, it is not seleted before the popupmenu comes up which makes the function non-intuitive. The user actually has to left click first to make the selection, the right click. This is the same for MS list boxes, ar any control.

Thanks in advance for any advice.
 
I had this same problem in a project I am currently working on using tree view and list view controls. Moving the code to pop up the menu to the control's mouse_up event worked for me. I cannot say whether this will work for any other control types since I have not tried it.

Vince
 
I have tried that but no luck. Somehow I need to figure out how to fire the mouse_down event.

When you have spent all day trying to work through a problem, it is best to take a step back, reevaluate the problem, then work on the next project and never let the old one show its ugly face again!!
 
What context do you need to fire the mousedown event from? If you need to fire it from another event, you just have to call it the same way you call any other proc. Of course, this can open a big can of worms, since you could fire other events as well.

Bob
 
Here is the code I'm using.
I guess firing the mouse down event isn't such a good idea. I just need to make sure that the item that is "right clicked" is actually selected before the popup menu. I know it can be done as I have some eBay software that uses this same grid and has the desired effect when you right click.

Private Sub grdSavedSearches_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)
On Error GoTo Err

If Button = vbRightButton Then
If grdSavedSearches.Rows <> 0 Then
Call PopupMenu(mnuRightClickSavedSearches)
End If
End If

ProcExit:
On Error Resume Next
Exit Sub
Err:
MySubName = &quot;grdItems_MouseUp&quot;
Call LogError(Err, mModName, MySubName, &quot;&quot;)
Resume ProcExit
End Sub

When you have spent all day trying to work through a problem, it is best to take a step back, reevaluate the problem, then work on the next project and never let the old one show its ugly face again!!
 
Ok, I did some research on this, and this is relevant:


Apparently, there's a bug in the DataGrid control that returns 0 for either left or right, 1 if right is pushed while left held down, and 2 if the reverse. Apparently, this was fixed with sp3. Perhaps you don't have a late enough sp installed?

HTH

Bob
 
The problem with standard MS controls is that the right click does not select the item. However with the Sheridan ssDBgrids I use this technique - you may need to work on it for your use let me know if any probs.

In MouseDown event

If SSDBGrd1.RowContaining(Y) = -1 Then Exit Sub
If Button = vbRightButton Then
If SSDBGrd1.SelBookmarks.Count < 1 Then
SSDBGrd1.SelBookmarks.RemoveAll
SSDBGrd1.Bookmark = SSDBGrd1.FirstRow
If SSDBGrd1.Row + SSDBGrd1.RowContaining(Y) > SSDBGrd1.VisibleRows - 1 Then
Exit Sub
End If
SSDBGrd1.Row = SSDBGrd1.Row + SSDBGrd1.RowContaining(Y)
End If
PopupMenu ....
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top