[Gambas-user] Building a custom MyComboBox

Tobias Boege taboege at ...626...
Mon Mar 3 20:55:20 CET 2014


On Mon, 03 Mar 2014, Matti wrote:
> I'm playing around with a ComboBox that should have some special features.
> Looked into the sources and found out how to create and inherit it.
> Subs, Functions and Events  work.
> 
> But one thing is a complete riddle to me:
> In the wiki, it says: "For example, you can create a custom MyListBox class that inherits ListBox <http://gambasdoc.org/help/comp/gb.qt/listbox?view> but allows to associate a tag with each list item."
> That's exactly what I'd need for MyComboBox: each list item with a tag (ID from a database).
> 
> Could someone give me a hint how to do that?
> Thanks, Matti
> 

You could have a

Private $aTags As New Variant[]

in your class which associates a Variant with an item via the item's index.
You need to maintain that array, though. Watch out for the Add(), Clear()
and Remove() methods and the List property! I'm not familiar with the
sources, so I don't know if there is a smarter way (and I'm assuming that
you write the extended ComboBox in Gambas).

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list