I Ian Gordon-Brown Member Licensed User Longtime User Jan 11, 2021 #1 Hello All The B4XCombo box allows you to add a List to it via the SetItems method. Is there anyway we can modify the number of columns, to include hidden columns, which can be referenced later? Thanks Ian
Hello All The B4XCombo box allows you to add a List to it via the SetItems method. Is there anyway we can modify the number of columns, to include hidden columns, which can be referenced later? Thanks Ian
I Ian Gordon-Brown Member Licensed User Longtime User Jan 11, 2021 #2 Actually - hold off - I think I may have the answer. Upvote 0
I Ian Gordon-Brown Member Licensed User Longtime User Jan 11, 2021 #3 Actually I don't it is not possible (to my knowledge) to return anything but a string from the combo box, so please help away. Upvote 0
Actually I don't it is not possible (to my knowledge) to return anything but a string from the combo box, so please help away.
Erel B4X founder Staff member Licensed User Longtime User Jan 12, 2021 #4 Use a Map that maps between the item text and any other data you need. Upvote 0
I Ian Gordon-Brown Member Licensed User Longtime User Jan 12, 2021 #5 Hello Erel. Thanks for prompt reply. Really appreciated. What I did initially was add the ID on the end, separated by a '-' and then split the data after selection - I will look at the map item and see how it works. It is a pity you can't retrieve a list (update maybe???). Have a great day. Upvote 0
Hello Erel. Thanks for prompt reply. Really appreciated. What I did initially was add the ID on the end, separated by a '-' and then split the data after selection - I will look at the map item and see how it works. It is a pity you can't retrieve a list (update maybe???). Have a great day.
udg Expert Licensed User Longtime User Jan 12, 2021 #6 As @Erel suggested, you can set a map where the key is the label you pass to the standard ComboBox and the value is anything you want to associate with it. Another approach is to design your own ComboBox class (CustomView). I did something similar in order to "hide" the need for an external (to the class) map. In my case the "trick" was to set a new internal type and the corresponding internal list: Code: Copy Type dgCB_Item (cLabel As String, cValue As Object) Private dgItems As List Clearly "cLabel" is used for the standard Combobox/Spinner while cValue could be anything. Upvote 0
As @Erel suggested, you can set a map where the key is the label you pass to the standard ComboBox and the value is anything you want to associate with it. Another approach is to design your own ComboBox class (CustomView). I did something similar in order to "hide" the need for an external (to the class) map. In my case the "trick" was to set a new internal type and the corresponding internal list: Code: Copy Type dgCB_Item (cLabel As String, cValue As Object) Private dgItems As List Clearly "cLabel" is used for the standard Combobox/Spinner while cValue could be anything.
I Ian Gordon-Brown Member Licensed User Longtime User Jan 12, 2021 #7 Thank you all. Using the map object worked well. Much appreciated In VBA it would be called the scripting runtime Last edited: Jan 12, 2021 Upvote 0
Thank you all. Using the map object worked well. Much appreciated In VBA it would be called the scripting runtime