Clearing a combobox's text area in code

Ricky D

Well-Known Member
Licensed User
Longtime User
I am wondering how do I clear the text part of a combobox on a form?

It doesn't have a text property and setting SelectedIndex to -1 does nothing.

regards, Ricky
 

klaus

Expert
Licensed User
Longtime User

JOTHA

Well-Known Member
Licensed User
Longtime User
... another question ...

In this case I have another question:

Is it possible to add text to a combobox an save it?

I mean on the PocketPC, not on the desktop.

Example:

You have a combobox with 4 predefined words in it.

Apple
Bread
Eggs
Butter

Now you want to add No5, for example "Milk", and you want to save it to use it another time.

Is this possible (and how)?

THANKS if someone knows a solution.
 

Ricky D

Well-Known Member
Licensed User
Longtime User
Thanks

Thanks Agraham, that works just right :)

Klaus: I need to have it clear when I add a new DailyTarget entry. The field has no default - I have designed it this way.

Jotha: use the Add method of the combobox to add new items. If you store them in a database then you'll need to add a new record to it too. I'm using SqlLite as my database.
 

klaus

Expert
Licensed User
Longtime User
Hello JOTHA,

You can do it that way:
- add a TextBox, where the user can input the new text.
- add a Button, when clicking it, the program adds the new text in the Combobox.
- save all the values and their number in aread this file at file when closing the program
- read this file at the start of the program and initialize the ComboBox.

I am using this way of dooing in this program http://www.b4x.com/forum/share-your-creations/1316-expense-tracker.html in the Config panel.

Best rgards.
 

RandomCoder

Well-Known Member
Licensed User
Longtime User
Adding new items is simple enough, you just need to use ComboBox1.Add("value")
If you want to save this for the next time the program is loaded then you need to store the values somewhere.
This could be an ini file or the simplest method would be to use a table to store the values, saving and loading to a csv file.

Regards,
RandomCoder
 
Top