ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Context menu (https://www.excelbanter.com/excel-programming/363786-context-menu.html)

cmpcwil2[_27_]

Context menu
 

Hi,
Is it possible to have a right click menu display when you right clic
on an object such as a VB combobox? I can get the menu to appear whe
right clicking on a cell but not on a combobox.

Dim NewControl As CommandBarControl
Set NewControl = Application.CommandBars("cell").Controls.Add
With NewControl
.Caption = "Clear Combo"
.OnAction = "Clear"
.BeginGroup = True
End With

Many thank

--
cmpcwil
-----------------------------------------------------------------------
cmpcwil2's Profile: http://www.excelforum.com/member.php...fo&userid=3341
View this thread: http://www.excelforum.com/showthread.php?threadid=55025


Ardus Petus

Context menu
 
Private Sub ComboBox1_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)

Upon right-click, you can show your own popup menu

HTH
--
AP

"cmpcwil2" a écrit
dans le message de news:
...

Hi,
Is it possible to have a right click menu display when you right click
on an object such as a VB combobox? I can get the menu to appear when
right clicking on a cell but not on a combobox.

Dim NewControl As CommandBarControl
Set NewControl = Application.CommandBars("cell").Controls.Add
With NewControl
Caption = "Clear Combo"
OnAction = "Clear"
BeginGroup = True
End With

Many thanks


--
cmpcwil2
------------------------------------------------------------------------
cmpcwil2's Profile:
http://www.excelforum.com/member.php...o&userid=33411
View this thread: http://www.excelforum.com/showthread...hreadid=550257




Ardus Petus

Context menu
 
This will show your customized "cell" menu upon right-clicking on the combo.

Private Sub ComboBox1_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
If Button = 2 Then
CommandBars("cell").ShowPopup
End If
End Sub

HTH
--
AP

"cmpcwil2" a écrit
dans le message de news:
...

Hi,
Is it possible to have a right click menu display when you right click
on an object such as a VB combobox? I can get the menu to appear when
right clicking on a cell but not on a combobox.

Dim NewControl As CommandBarControl
Set NewControl = Application.CommandBars("cell").Controls.Add
With NewControl
Caption = "Clear Combo"
OnAction = "Clear"
BeginGroup = True
End With

Many thanks


--
cmpcwil2
------------------------------------------------------------------------
cmpcwil2's Profile:
http://www.excelforum.com/member.php...o&userid=33411
View this thread: http://www.excelforum.com/showthread...hreadid=550257




cmpcwil2[_28_]

Context menu
 

Thank you thats great, don't why I didn't try that! Thanks agai

--
cmpcwil
-----------------------------------------------------------------------
cmpcwil2's Profile: http://www.excelforum.com/member.php...fo&userid=3341
View this thread: http://www.excelforum.com/showthread.php?threadid=55025


cmpcwil2[_29_]

Context menu
 

I have a context menu to appear upon a right click of the mouse whilst
on a combo box. However the menu appears twice once when you right
click and then again upon selection of a menu item, I have implemented
the code above in a class module so not sure if this is the problem,
here is my code:

set up menu in module:

Dim NewControl As CommandBarControl
Set NewControl = Application.CommandBars("cell").Controls.Add
With NewControl
..Caption = "Clear Combo"
..BeginGroup = True
End With

call the menu from class module depending upon which combo box has
focus:
Sub ComboGroup_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)

If Button = 2 Then
CommandBars("cell").ShowPopup
ComboGroup.Text = ""
ComboGroup.clear


End If
End Sub

Can anyone help me on this? thanks


--
cmpcwil2
------------------------------------------------------------------------
cmpcwil2's Profile: http://www.excelforum.com/member.php...o&userid=33411
View this thread: http://www.excelforum.com/showthread...hreadid=550257



All times are GMT +1. The time now is 03:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com