Print Page | Close Window

Designer & Programatically filling ComboBoxs

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=7847
Printed Date: 03 March 2025 at 5:55am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Designer & Programatically filling ComboBoxs
Posted By: DigiDog
Subject: Designer & Programatically filling ComboBoxs
Date Posted: 22 August 2007 at 12:37am
I have been able to create toolbars with ComboBoxes etc. and can populate them in Designer but I need to populate the ComboBox in code.  Should be simple. Can anyone help?
 
Many thanks



Replies:
Posted By: Oleg
Date Posted: 22 August 2007 at 3:01am
Hello,
After you load designer file, find this combo:
 
CXTPControlComboBox* pCombo = (CXTPControlComboBox*)pCommandBars->FindControl(...);
 
and fill using pCombo->AddString method.


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


Posted By: DigiDog
Date Posted: 22 August 2007 at 7:55am
Thanks Oleg but I am affraid I need it spelled out a little more. I am not finding CXTPControlComboBox or pCommandBars. Thanks for your patience.


Posted By: DigiDog
Date Posted: 22 August 2007 at 11:05am
Oleg, I have it working partly. But I am unable to set in initial entry for the Combo Box. I get errors when using Methods that I would expect to work.
 
Thanks again for your help.
 
        Dim pCombo As CommandBarComboBox
        Set pCombo = CommandBars.DesignerControls.Find(, 1036)

            pCombo.AddItem ("Default")      'Works!
            pCombo.AddItem ("Profile1")     'Works!
            pCombo.AddItem ("Profile2")     'Works!
            pCombo.ListIndex = 1            'Method 'ListIndex' of object 'ICommandBarComboBox' failed
            'or
            pCombo.Text = "Default"         'Method 'Text' of object 'ICommandBarComboBox' failed
            Debug.Print pCombo.ListCount    'Works!


Posted By: Oleg
Date Posted: 22 August 2007 at 12:42pm
Hi,
 
you wrote in MFC forum, so I gave you MFC answer.
 
for ActiveX instead of CommandBars.DesignerControls.Find
use CommandBars.FindControl


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


Posted By: DigiDog
Date Posted: 22 August 2007 at 12:50pm

Sorry for the confusion. I will try to be more careful in the future.

Now, how do I initialize the combo box with a selection. Nothing seems to be provided to do that. The box always comes up empty until somethng is selected via the mouse etc. I want it to come up with the entry that was there the last time the application was closed.

 

Many thanks



Posted By: Oleg
Date Posted: 22 August 2007 at 1:06pm
Hi,
So Combo.ListIndex Property doesn't work for you ?


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


Posted By: DigiDog
Date Posted: 22 August 2007 at 1:08pm
OK, That did it. Thanks for your patient help.



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