A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Enabeling right click on multi-select listboxes



 
 
Thread Tools Display Modes
  #1  
Old September 2nd, 2006, 03:10 AM posted to microsoft.public.access.forms
j_p_s
external usenet poster
 
Posts: 2
Default Enabeling right click on multi-select listboxes

Hi all:

I found a trick that I thought I would share with anyone that could
benefit from it...

Basically I was trying to use a popup shortcut menu on a listbox in ony
of my forms. However, I also wanted to have the multi-select option
enabled. The trouble is that when you right click on a multi-select
listbox, the list then sets a single item selected where ever you right
clicked in the list.

Well... I love a good challange. I figured out that if you put a label
on your form, and then set the width to 0", you could set the focus to
it on the mouse down event of the list box when the button parameter is
2 (indicating a right click).

So basically what happens is, on a mouse down event, if the "Button"
parameter is a 2, then set the focus to the label. Because the label
has a width of 0", the user does not see that the focus has been passed
to another control. And because the focus has been changed, the on
click event never fires, and your list still has the multi items
selected. And bingo, the popup menu works, so you have all your list
items selected, and a right click shortcut menu.

Here is my on mouse down event code:
==========================================

Private Sub list_Contents_MouseDown(Button As Integer, Shift As
Integer, X As Single, Y As Single)

'If right clicked, then set the focus to the focus point
If Button = 2 Then

'set the focus to my label with a 0" width
Me.FocusPoint.SetFocus

End If

End Sub
==========================================

The reason I am posting this is becaus I was looking for a solution for
this, and found that a few other people were also looking for a work
around for this.

Just thought I would share. = )

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:49 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.