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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SmartMenuXP - Disable Checkbox when other clicked 1

Status
Not open for further replies.

HydraNL

Technical User
May 9, 2005
74
NL
Hi,

I hope someone has used or is using SmartMenuXP en could help me out.

I have a menu with several captions. When I click on a caption the checkbox gets checked... So far so good...

What I want is; When I click on another caption I want the 1st caption to be unchecked... an so on. Something like:
Code:
Case "KeyAlpha"
    If KeyAlpha.Checked = True Then
        KeyBeta.Checked = False
        KeyDelta.Checked = false
    End if
    
    If KeyBeta.Checked = True Then
         KeyAlpha.Checked = False..... and so on
Of course the above code makes no sence in the SmartMenuXP-coding, but it's just an example.
 
Each menu item should have it's own onclick event. In each onclick event you could call a common subroutine and pass it a reference to the item actually clicked. The subroutine would just clear ALL of the items, then reset the one that was passed to it.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
I understand what to do..., but not how to implement that in the coding of SmartXP. An example would help more.
 
SmartMenuXP has a single click event for all menu items, which is a little different from regular VB menus.

Clicking a menu item fires the Click event. The actual menu item is identified by the ID parameter which returns the unique menu item identifier.

To make a group of menu choices, you should add all the option items as checkbox, specifying smiCheckBox style in Add method.

See the following code.
___
[tt]
With SmartMenuXP1.MenuItems
.Add "options", , smiCheckBox, "Option 1", , , , smiChecked
.Add "options", , smiCheckBox, "Option 2", , , , smiUnchecked
.Add "options", , smiCheckBox, "Option 3", , , , smiUnchecked
.Add "options", , smiCheckBox, "Option 4", , , , smiUnchecked
.Add "options", , smiCheckBox, "Option 5", , , , smiUnchecked
.Add "options", , smiCheckBox, "Option 6", , , , smiUnchecked
End With[/tt]
___

This code adds the option menu items to a sub-menu with key property set to "options".

Note that the first item is added as checked initially by specifying smiChecked value in Add method. You can choose any other option to be checked initially, or you can check an option based on application settings during startup.

Later, when you handle the Click event of the control. You should take care how the items are checked and unchecked. If the ID of the menu item is in the range of option items, you should check that menu item and clear the others in the range.

Suppose that option items fall in the range 30 to 35, you should code your Click event like this.
___
[tt]
Private Sub SmartMenuXP1_Click(ByVal ID As Long)
'...
Dim N As Long
Select Case ID
Case 30 To 35 'range of option menu items
'check this menu option and clear others
For N = 30 To 35
SmartMenuXP1.MenuItems.Value(N) = N = ID
Next
End Select
'...
End Sub[/tt]
___

Note that scanning from items 30 to 35 is just an example. Actual item identifier depends upon the order of menu items, which is assigned increasingly as menu items are added to the control.

You shoud better find the range experimentally by clicking the first and last option items and examining the ID value using Debug.Print.

If the structure of the menu is completely dynamic, and you expect that the ID of different menu options may change, you should better assign unique key to each menu item and refer to your menu items using keys, instead of hard-coding with menu identifiers.
 
Thanks for the reply Hypetia. The first thing i already used. It works fine.

I tried your code without any result. To bad.

this is the code I already had:
Code:
.Add "mnuExtra", "options", , "Change Skin"   '(31)
                .Add "options", "mSkin1", smiCheckBox, "Aisi", , , , smiChecked   '(32)
                .Add "options", "mSkin2", smiCheckBox, "Autumn", , , , smiUnchecked   '(33)
                .Add "options", "mSkin3", smiCheckBox, "Blue and Orange", , , , smiUnchecked   '(34)
                .Add "options", "mSkin4", smiCheckBox, "Blue Neon", , , , smiUnchecked   '(35)
                .Add "options", "mSkin5", smiCheckBox, "BlueSteel", , , , smiUnchecked   '(36)
                .Add "options", "mSkin6", smiCheckBox, "Crimsom", , , , smiUnchecked   '(37)
                .Add "options", "mSkin7", smiCheckBox, "Cyan Neon", , , , smiUnchecked   '(38)
                .Add "options", "mSkin8", smiCheckBox, "Dark Win in Blue", , , , smiUnchecked   '(39)
                .Add "options", "mSkin9", smiCheckBox, "Dark Win in Green", , , , smiUnchecked   '(40)
                .Add "options", "mSkin10", smiCheckBox, "Green", , , , smiUnchecked   '(41)
                .Add "options", "mSkin11", smiCheckBox, "Green Neon", , , , smiUnchecked   '(42)
                .Add "options", "mSkin12", smiCheckBox, "Lilac", , , , smiUnchecked   '(43)
                .Add "options", "mSkin13", smiCheckBox, "Noir", , , , smiUnchecked   '(44)
                .Add "options", "mSkin14", smiCheckBox, "Ocean Nights", , , , smiUnchecked   '(45)
                .Add "options", "mSkin15", smiCheckBox, "Omega", , , , smiUnchecked   '(46)
                .Add "options", "mSkin16", smiCheckBox, "Purple Neon", , , , smiUnchecked   '(47)
                .Add "options", "mSkin17", smiCheckBox, "Red Neon", , , , smiUnchecked   '(48)
                .Add "options", "mSkin18", smiCheckBox, "Red", , , , smiUnchecked   '(49)
                .Add "options", "mSkin19", smiCheckBox, "River", , , , smiUnchecked   '(50)
                .Add "options", "mSkin20", smiCheckBox, "Rose", , , , smiUnchecked   '(51)
                .Add "options", "mSkin21", smiCheckBox, "Violet and Brown", , , , smiUnchecked   '(52)
                .Add "options", "mSkin22", smiCheckBox, "Wire Frame", , , , smiUnchecked   '(53)
                .Add "options", "mSkin23", smiCheckBox, "Wood", , , , smiUnchecked   '(54)
                .Add "options", "mSkin24", smiCheckBox, "Yellow Neon", , , , smiUnchecked   '(55)
                .Add "options", "mSkin25", smiCheckBox, "Zinc", , , , smiUnchecked   '(56)
Code:
Private Sub SmartMenuXP1_Click(ByVal ID As Long)
Dim N As Long

    With SmartMenuXP1.MenuItems
    Select Case .Key(ID)
    Case 32 To 56
       For N = 32 To 56
           SmartMenuXP1.MenuItems.Value(N) = (N) = ID
       Next
End Select
When I click on another item in the menu it does not remove the other check.

How do I give the item(s) a unique ID?
Thanks in advance.
 
Your code is just fine except for one thing in the Click event.

Instead of
[tt]Select Case .Key(ID)[/tt]

Your should use
[tt]Select Case ID[/tt]

>How do I give the item(s) a unique ID?
You don't need to. The control assigns them a unique id itself. However, you cannot specify of your own as I mentioned. You can only specify your own key, which you are already doing.
 
Thanx Hypetia...

Perhaps i have to read more carefull the next time.. hihihi. Do you know where to find some kind of help or more samples working with SMXP?
 
See my last reply in thread222-1115949. I am only aware of the website that hosts the control. You can find a demo project there, which I hope you already have.

Moreover, you can find online reference to the all member properties, methods and events. I think that is sufficient for get going.
 
Thanks man....
I already had the demo-project... ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top