Hi,
On Sun, 28 Dec 2003 23:05:55 +0100, Leon wrote:
I need to change form's standard context menu code.
Eg. I want to order records by my own code.
Can I make it, or must I create other context menu
and link it to my form??
The common approach would be to create your own CommandBar and use that.
Use the form's (or a control's) property-sheet to set the "Shortcut Menu
Bar"-property.
I'd like to know also how to enable/disable contextmenu's
items ;)
Below is a function I am using to update a bar's items all at once (check
for line-breaks).
The easiest way to call it will be to use the ShortcutMenuBar-property
directly:
MenuItems_Dis_E nable lstBox.Shortcut MenuBar, _
1, True, _
2, True, _
3, False,
The above sample targets the bar being used with the control "lstBox"
(whatever name that may be) and sets the enabled-prop of the first three
items (1, 2, 3). See the OH for "CommandBar s Collection Object" for more
detailed info.
Cheers,
Olaf [MVP]
--
My .02:
www.Resources.IntuiDev.com
'dis-/enable items within menus
Function MenuItems_Dis_E nable(strMenuNa me As String, ParamArray pvarIndx())
'************** *************** **************
'Name: MenuItems_Dis_E nable (Function)
'Purpose: dis-/enable single entries within commandbars/shortcut-menus
etc.
'Author: Olaf
'Date: October 29, 2001, 06:43:23
'Called by:
'Calls:
'Inputs: strMenuName: name of menu
' varIndx(): (Parameter-array): Index of MenuItem
plus True/False (as variant)
'
'Note: Indexes of commandbars start out at 1!
'Output: -
'************** *************** **************
Dim intCounter As Integer
With CommandBars(str MenuName)
For intCounter = 0 To UBound(pvarIndx ) Step 2
.Controls(pvarI ndx(intCounter) ).Enabled =
CBool(pvarIndx( intCounter + 1))
'Debug.Print .Controls(pvarI ndx(intCounter) ).Caption & " -> ";
..Controls(pvar Indx(intCounter )).Enabled
Next intCounter
End With
End Function