Print Page | Close Window

Index param in AddItem Method

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=390
Printed Date: 26 April 2024 at 9:24pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Index param in AddItem Method
Posted By: jamauss
Subject: Index param in AddItem Method
Date Posted: 27 January 2004 at 12:18pm
I am using the ActiveX XTremeCommandBars. I am putting a combo box into my toolbar. When I call the AddItem method and pass a string and an index value, no items show up in my combo box unless [index] is 1 and then only goes 2, 3, 4 as I add more items. Why does it do this? Is it a requirements to only have sequential index values starting at 1?



Replies:
Posted By: robs
Date Posted: 04 February 2004 at 9:09pm

jamauss,

I think this is normal. It appears that the 'index' parameter is like the 'before' parameter in a VB collection (although the object doesn't support named arguments).

 c.AddItem "Test1", 1
 c.AddItem "Test2", 2
 c.AddItem "Test3", 2

Is like saying:

add Test1 before anything

add Test2 before the 2nd item (if it exists)

add Test3 before the 2nd item (if it exists)

So the list would be: Test1,Test3, Test2

 

rob



Posted By: jamauss
Date Posted: 05 February 2004 at 7:19pm

OK, then why don't any of the items in my list appear?

Try adding items using index values like 3, 4, and 5 (in that order) and you'll see that no items appear in your combo box.

Also - there is no "ItemData"-type property for the combo boxes then so you can associate ID values with combo list items? That's practically the whole purpose for having combo boxes. Some functionality is severely lacking here.



Posted By: robs
Date Posted: 05 February 2004 at 8:14pm

Yep, I see what you are saying.

I think what I said before is correct, with an exception:

c.AddItem "Test2",2 will add "Test2" before item 2 if it exists-however, if it does not then it won't add it at all.

I agree with you that the combo boxes are lacking. One would expect them to behave like a standard combo box.

Perhaps the folks at Codejock with recognize this as a bug, or consider it for a future enhancement.

Would you consider using a custom control (standard ComboBox) instead? Then you should have the functionality of a standard combobox. It's not the best sollution but...

Drop a combo on your form (Combo1)

Dim mCustom     As ICommandBarControlCustom

Set mCustom = CommandBars.Add(xtpControlCustom, id, label)
With Combo1
   mCustom.Handle = .hWnd
   .AddItem "Item1"
    .AddItem "Item2"
    .ListIndex = 1
End With

 




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