Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Designer  &  Programatically filling ComboBoxs
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Designer & Programatically filling ComboBoxs

 Post Reply Post Reply
Author
Message
DigiDog View Drop Down
Newbie
Newbie
Avatar

Joined: 22 August 2007
Location: United States
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote DigiDog Quote  Post ReplyReply Direct Link To This Post Topic: Designer & Programatically filling ComboBoxs
    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
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
DigiDog View Drop Down
Newbie
Newbie
Avatar

Joined: 22 August 2007
Location: United States
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote DigiDog Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
DigiDog View Drop Down
Newbie
Newbie
Avatar

Joined: 22 August 2007
Location: United States
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote DigiDog Quote  Post ReplyReply Direct Link To This Post 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!
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
DigiDog View Drop Down
Newbie
Newbie
Avatar

Joined: 22 August 2007
Location: United States
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote DigiDog Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 22 August 2007 at 1:06pm
Hi,
So Combo.ListIndex Property doesn't work for you ?
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
DigiDog View Drop Down
Newbie
Newbie
Avatar

Joined: 22 August 2007
Location: United States
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote DigiDog Quote  Post ReplyReply Direct Link To This Post Posted: 22 August 2007 at 1:08pm
OK, That did it. Thanks for your patient help.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.078 seconds.