Print Page | Close Window

Help with LoadStateFromString

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=1639
Printed Date: 29 September 2024 at 6:06pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Help with LoadStateFromString
Posted By: JoshV
Subject: Help with LoadStateFromString
Date Posted: 09 January 2005 at 5:57pm

I have several dynamic toolbars with dropdown lists (xtpControlSplitButtonPopup) that change based upon the type of  'document' that a user has opened.  For example, I want to display 3 control buttons with 'A', 'B', and 'C' one time a user logs in and I want it to be 'D', 'E', and 'F' on the next login.

I'm fine loading these programically, but as soon as I use LoadStateFromString to try to restore the last position of each of the application's toolbars, I run into problems.  My dropdown lists no longer contain the values I programitacally load.  Instead they show the content of the lists as they were when I last called SaveStateToString. 

I can see where that might make sense, but when I try delete these list items and re-add them with the correct items, the control doesn't update on the screen.  If I had 'A', 'B', and 'C' showing the last time I called SaveStateToString and then run code such as:

-------------------

Public ToolbarAssignment As CommandBar
Public ToolbatAssignmentPopup As CommandBarPopup

-------------------


Set ToolbarAssignment = CommandBars1.Add("Assignment", xtpBarTop)
With ToolbarAssignment.Controls
       
   Set ToolBarAssignmentPopup = .Add(xtpControlSplitButtonPopup, 0, "Assignments")
   ToolBarAssignmentPopup.ID = ID_ASSIGNPOPUP

End With

CommandBars1.LoadStateFromString    &nbs p;

ToolBarAssignmentPopup.CommandBar.Controls.DeleteAll
ToolBarAssignmentPopup.CommandBar.Controls.Add(xtpControlBut ton, 100, 'D')
ToolBarAssignmentPopup.CommandBar.Controls.Add(xtpControlBut ton, 101, 'E')
ToolBarAssignmentPopup.CommandBar.Controls.Add(xtpControlBut ton, 102, 'F')

---------------------


After this, the control still shows 'A', 'B', and 'C'  When I access the ToolBarAssignmentPopup buttons through code, I correctly see 'D', 'E', and 'F'.  Do I need to do something to force the control to repaint or refresh?  Does my variable ToolBarAssignmentPopup no longer reference the same node in the commandbar after calling LoadStateFromString?

Thanks.




Replies:
Posted By: SuperMario
Date Posted: 10 January 2005 at 7:17am
First make sure that ToolBarAssignmentPopup  was added to the toolbar before the layout was saved.

Try:
       CommandBars.LoadStateFromString

       Set ToolBarAssignmentPopup = CommandBars.ActiveMenuBar.FindControl(xtpControlSplitButt onPopup, ID_ASSIGNPOPUP, ,TRUE)
        With ToolBarAssignmentPopup .CommandBar.Controls
            .Add xtpControlBut ton, 100, 'D'
            .Add xtpControlBut ton, 101, 'E'
            .Add xtpControlBut ton, 102, 'F'
         End With
   


Posted By: JoshV
Date Posted: 13 January 2005 at 11:24am

When I call FindControl as outlined above, it sets ToolBarAssignmentPopup to Nothing.

If I just reference the object variable without setting it in the FindControl call, it is not Nothing (ie ToolbarAssignmentPopup is Nothing = False).  This object reference (ToolbarAssignmentPopup) allows me to call ToolbarAssignmentPopup.CommandBar.Control.DeleteAll etc, without generating an error, but they have no effect on the screen.

If I don't call LoadStateFromString in the code segment you gave above, the FindControl works without a problem and returns a reference to the control that I want.  That would be fine, except I need the toolbar positioning that I can only get from LoadStateFromString.



Posted By: SuperMario
Date Posted: 13 January 2005 at 1:14pm
In the saved layout do you have a popup with Id = ID_ASSIGNPOPUP?



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