Print Page | Close Window

How to disable an item in toolbar?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=9083
Printed Date: 17 June 2025 at 8:37pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to disable an item in toolbar?
Posted By: lexicon
Subject: How to disable an item in toolbar?
Date Posted: 12 December 2007 at 8:28am
How to disable an item in toolbar?



Replies:
Posted By: Oleg
Date Posted: 12 December 2007 at 11:04am
Hi,
Please start learning from our samples. They have a lot of such things.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: lexicon
Date Posted: 13 December 2007 at 2:39am
Sorry but even if i'm seeing you doing it in your samples, i still don't understand how you are doing it


Posted By: ijwelch
Date Posted: 13 December 2007 at 7:36am
It will usually be in the CommandBars_Update event.


Posted By: lexicon
Date Posted: 13 December 2007 at 7:46am
And how can i refer to the spesific item in Toolbar?


Posted By: jcollier
Date Posted: 13 December 2007 at 1:01pm
Set up a boolean variable for each button that you want to enable/disable.

In your CommandBars_Update event, set the enabled property for each button  to the value of the corresponding variable, like so (or you could specify each button exactly instead of using Select Case):

Private Sub CommandBars_Update(ByVal Control As XtremeCommandBars.ICommandBarControl)

    Select Case Control.ID
        Case ID_FIRSTPAGEOFDOCUMENT
            Control.Checked = blnFirstPageOfDocument
           
        Case ID_SUPERVISORCHECK
            Control.Checked = blnSupervisorCheck
            Control.Enabled = blnSupervisorCheckEnable
           
        Case ID_PAGEDOWNNEXTDOCUMENT
            Control.Checked = blnPageDownToNextDocument
           
        Case ID_SPELLCHECKTOGGLE
            Control.Checked = blnSpellCheck
           
        Case ID_HOMEANDENDKEYENDOFLINETOGGLE
            Control.Checked = blnHomeAndEndKey
           
        Case ID_ENTERKEYPAGEDOWN
            Control.Checked = blnEnterKeyPageDown
       
        Case ID_SUPERVISORCHECKNOTES
            Control.Enabled = blnSupervisorCheckComments
    End Select

End Sub



When you want to change the enabled state of a button, you simply set the value of the corresponding boolean variable to the desired value.  The update event will then take over and enable/disable the button for you.


Posted By: lexicon
Date Posted: 13 December 2007 at 1:40pm
The Update event happens all the time
I want the program to start with a button disabled (which i can do with Update event) and then after a button clicked to disable another one
Lets say you have a New button and a Save Button
The Save button will be disabled and when the New button clicked, the New button will be disabled and the Save button will be enabled
 
Thank you very much for your help


Posted By: jcollier
Date Posted: 13 December 2007 at 1:48pm
Right.  What I would do there is set up boolean variables in the General Declaration of the form for each of your 2 buttons.

In Form_Load set the booleans to the disable/enable values you want.

In CommandBars_Update set the enabled property of each button to the boolean value

In the click event of each button, set the boolean values to the desired state.

That should do it.


Posted By: lexicon
Date Posted: 13 December 2007 at 2:34pm
Thanks a lot, that's what i want


Posted By: Oleg
Date Posted: 14 December 2007 at 3:03pm
Jason, Thanks for help. :-)

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net