How to add new item to combo box?
-
Hi Chee ken, Try
ComboBox1.Items.Add("blablabla")
Good luck, JohanMy advice is free, and you may get what you paid for.
-
Hi Chee ken, Try
ComboBox1.Items.Add("blablabla")
Good luck, JohanMy advice is free, and you may get what you paid for.
Thanks for reply. The item add sucessfully. Can i ask one more question, how to assign the value for it ? or its value is -1? And why it not show while the program load ( it locate at the second item at the drop down list and the first one is blank ) ? thanks.
Best regards, Chee ken
-
Thanks for reply. The item add sucessfully. Can i ask one more question, how to assign the value for it ? or its value is -1? And why it not show while the program load ( it locate at the second item at the drop down list and the first one is blank ) ? thanks.
Best regards, Chee ken
The
.Add
method will usually put the value at the end of the list. If you want to add the item at a specific point in the list, use:dim YourIndexNumber as Integer 'Determine here at what position you want to insert your value, 'and assign this position's index number to YourIndexNumber. 'Index starts at 0 ComboBox1.Items.Insert(YourIndexNumber , "blablabla")
I am sorry, but I don't quite understand the second part of your question. -- modified at 4:29 Friday 9th February, 2007My advice is free, and you may get what you paid for.
-
Hi Chee ken, Try
ComboBox1.Items.Add("blablabla")
Good luck, JohanMy advice is free, and you may get what you paid for.
-
And what hapend when combobox source is a table?. Necesary you must insert into that table the new item then. In addition you must refresh the combobox after. ¿What do you think?. Thanks.
It depends on two things: 1. do you use databinding between the table and combobox? If you do, then yes, you would need to insert the entry into the table and refresh the databinding. If you fill the combobox with your own code though, and just use the table as a source, you could insert the entry straight into the combobox. 2. do you need the entry for your combobox to be saved into the table, or does the table only contain the basic entries, and are new entries just temporary in nature? If you need the new entries to be saved, use databinding, and write the entry into the table, rather than to the combobox. If they are only temporary, write them straight to the combobox, and do not use databinding. Is that what you meant? Johan
My advice is free, and you may get what you paid for.