aIDs is an array of Integers (You can declare an array of Strings if is your case, or an array of Variants), and you can assing that array to a Variant variable, as is the case of the Tag property of the combobox.
*_________________________* *Lic. Daniel Quintero Rojas* *¡Saludos desde México!________* On Mon, Mar 3, 2014 at 2:29 PM, Matti <matti.e...@vodafone.de> wrote: > Thanks, Daniel. > But I don't understand how you can assign the aIDs Integer[] to the > ComboBox.Tag that is a variant? > Anyway, I'd prefer a custom combo, since I need it often in a form and > don't want to write everything again and again. > > Am 03.03.2014 21:04, schrieb Daniel Quintero: > > I use this code (Obviously, without creating a custom combo): > > > > Public Sub LoadCombo() > > Dim aIDs As New Integer[] > > Dim sQuery As New String > > > > cboSample.Clear > > > > ' Load Data > > hResult = $hConn.Exec("select ID, desc from MyTable") > > http://gambasdoc.org/help/comp/gb.qt4/combobox?v3 For Each hResult > > cboSample.Add(hResult!desc) > > aIDs.Add(hResult!ID) > > Next > > cboSample.Tag = aIDs > > > > End > > > > Public Sub cboSample_Change() > > If cboSample.Index > -1 Then > > Message("ID associated with '" & cboSample.Text & "': " & > > cboSample.Tag[cboSample.Index]) > > Endif > > End > > > > Regards > > > > *_________________________* > > *Lic. Daniel Quintero Rojas* > > > > *¡Saludos desde México!________* > > > > > > > > On Mon, Mar 3, 2014 at 1:55 PM, Tobias Boege <tabo...@gmail.com> wrote: > > > >> 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 > >> > >> > >> > ------------------------------------------------------------------------------ > >> Subversion Kills Productivity. Get off Subversion & Make the Move to > >> Perforce. > >> With Perforce, you get hassle-free workflows. Merge that actually works. > >> Faster operations. Version large binaries. Built-in WAN optimization > and > >> the > >> freedom to use Git, Perforce or both. Make the move to Perforce. > >> > >> > http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk > >> _______________________________________________ > >> Gambas-user mailing list > >> Gambas-user@lists.sourceforge.net > >> https://lists.sourceforge.net/lists/listinfo/gambas-user > >> > > > ------------------------------------------------------------------------------ > > Subversion Kills Productivity. Get off Subversion & Make the Move to > Perforce. > > With Perforce, you get hassle-free workflows. Merge that actually works. > > Faster operations. Version large binaries. Built-in WAN optimization > and the > > freedom to use Git, Perforce or both. Make the move to Perforce. > > > http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk > > _______________________________________________ > > Gambas-user mailing list > > Gambas-user@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/gambas-user > > > > > > ------------------------------------------------------------------------------ > Subversion Kills Productivity. Get off Subversion & Make the Move to > Perforce. > With Perforce, you get hassle-free workflows. Merge that actually works. > Faster operations. Version large binaries. Built-in WAN optimization and > the > freedom to use Git, Perforce or both. Make the move to Perforce. > > http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk > _______________________________________________ > Gambas-user mailing list > Gambas-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gambas-user > ------------------------------------------------------------------------------ Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce. With Perforce, you get hassle-free workflows. Merge that actually works. Faster operations. Version large binaries. Built-in WAN optimization and the freedom to use Git, Perforce or both. Make the move to Perforce. http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user