Print Page | Close Window

Changing .Enabled in design time

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=14159
Printed Date: 07 October 2024 at 12:29am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Changing .Enabled in design time
Posted By: Mess
Subject: Changing .Enabled in design time
Date Posted: 27 April 2009 at 2:14pm
Hi,
 
I'm trying to set the visibility and to enable and disable controls at run-time. I'm using Actions as described and have also read the sample code, but I don't seem to get it to work.
 
I created the action before everything else is created, and add this simple code when clicking a button:
 
    Dim Action As CommandBarAction
    Set Action = CommandBars.Actions(ID_HTML_EDIT)
 
When I change the Action.Enabled the properties changes as they should,  but the button doesn't gray out of disappear as I want visually. What seems to be the problem here?
 
Thank you,
Bjarne



Replies:
Posted By: jpbro
Date Posted: 28 April 2009 at 6:48am
Here's some code that I just test that works. You need a form with a CommandBars control (CommandBars1) and a standard VB6 CommandButton control (Command1):


Option Explicit

Private mo_TestAction As CommandBarAction

Private Sub Command1_Click()
   mo_TestAction.Enabled = Not mo_TestAction.Enabled
End Sub

Private Sub Form_Load()

   With Me.CommandBars1
      Set mo_TestAction = .Actions.Add(100, "Action Test", "This is a test", "Testing Testing", "Test")
     
      .Item(1).Controls.Add xtpControlButton, 100, ""
      .Item(1).Controls.Add xtpControlButton, 101, "Test2"
      .Item(1).Controls.Add xtpControlButton, 102, "Test3"
     
      .EnableActions
   End With
End Sub


The key for me was to define the Action before adding the controls.


-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6



Posted By: Mess
Date Posted: 28 April 2009 at 9:00am
Thank you. I got this to work by setting the status bar to Nothing and then instantiating a new StatusBar after that.
 
Thanks.



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