473,395 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Adding items to combo box during run time

8
I am using VB6.0

I have two combo boxes , namely combo1 and combo2.
For E.g, I say Combo1.AddItem Combo1.Text to add a new item to the list during run time. In the drop down I do see the new item during run time. But It disappears in the next run time.

My question is , how can I save the newly added item to the Combo boxes list permanently so that in the next run time it should show the new added item along with the old items.

Please help.

Thanks
Pratibha
Jul 26 '07 #1
6 13097
hariharanmca
1,977 1GB
I am using VB6.0

I have two combo boxes , namely combo1 and combo2.
For E.g, I say Combo1.AddItem Combo1.Text to add a new item to the list during run time. In the drop down I do see the new item during run time. But It disappears in the next run time.

My question is , how can I save the newly added item to the Combo boxes list permanently so that in the next run time it should show the new added item along with the old items.

Please help.

Thanks
Pratibha
So you have to store it in database.
Jul 26 '07 #2
mysore
8
So you have to store it in database.
Yeah. I am using MS access.
Jul 26 '07 #3
pureenhanoi
175 100+
Yeah. I am using MS access.
after adding new item into ComboBox, insert it into database.
If u bind combobox into a table, it will be automatically added new item into table. If u was not, add new item by manual.
ComboBox1.AddItem Combo1.Text
Expand|Select|Wrap|Line Numbers
  1. sql = "INSERT INTO tableName '" & combo1.Text & "'"
  2. Conn.Excute sql
  3.  
later, u load all from and all item into combobox, new item will appear
Jul 26 '07 #4
Just a reminder....

If combobox items never have to change they can be set when the form and control are designed and will always revert to the original design contents when the application is restarted.

If the combobox items have to be set or changed at runtime and then have to be saved for next time, the items will have to be saved outside the application. This can be either in a database or in a separate data/text file (written with streamreader and writer). The combobox will have to be filled from and saved to the database or file each time the application is run.

This is one of those things that if you know you know, but if you don't you spend hours wondering why what you want to do doesn't work. And that's what the forums should help with.
Jul 27 '07 #5
fplesco
82
I am using VB6.0

I have two combo boxes , namely combo1 and combo2.
For E.g, I say Combo1.AddItem Combo1.Text to add a new item to the list during run time. In the drop down I do see the new item during run time. But It disappears in the next run time.

My question is , how can I save the newly added item to the Combo boxes list permanently so that in the next run time it should show the new added item along with the old items.

Please help.

Thanks
Pratibha
Hi there -

I can figure out your problem. Those values in the combo box that you said that are not gone after rerun, are really values it at your design time. Try to look at Combo box "List" property at the design time and you will those values.

Now, you may have wanted it all coming from your database (MS Access). What you gonna do is

I suppose that you know how and you are able to connect to the dbase and your recordset object is ready.

Combo1.clear -- This will clear the values from design time
If not rs.eof -- And load values extracted from your table in the dbase
Do until rs.eof
Combo1.AddItem rs!<Fieldname>
Loop
End if

This perhaps shed light to this problem.

Have a good day.
Jul 27 '07 #6
mysore
8
Thanks everyone. It worked. Your replies solved my problem.

Thank You.

Pratibha
Jul 27 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: 6thirty | last post by:
Hi, I've created a stocktaking database using Access XP. This is indexed by two fields - part number and shelf location. I am currently inputting all the data via a form. When I have entered a...
6
by: Reggie | last post by:
Hi and TIA! I have a bound combobox with rowsource set to value list, limit to list=true and NotInList procedure to add(or not) a value the user types in. This works fine and it does add the...
4
by: Gav | last post by:
I am using VS 2005 and am trying to add items to a combo box using C#. I know how to add simple text items but I am trying to add a value and some text ie. Value Text A First Text B ...
2
by: Dave | last post by:
Hi, I'm building a maintenance form for a table and some of the fields are textboxes (i.e name) and some should be dropdowns (i.e country of origin) When a user clicks 'Edit' in the...
6
by: vb | last post by:
Hi, I am new to .Net. I am using a Combo Box in my windows forms. I am adding the items by creating the instances and adding the same to the list. My questions/doubts are: 1. If I have 25 to...
1
by: stinehelferw | last post by:
I need a right-click menu on a form list control with combobox controls. I used View->Toolbars->Customize to create a toolbar. I added ComboBox through commands tab. I set properties to Popup...
0
by: mollyf | last post by:
I've got a combo box that I want to bind a collection to. I got the error "Complex Data Binding accepts as a data source either an IList or an IListSource" so I tried using the BindingSource,...
2
by: Rajesh | last post by:
Hi, I need to create a set of controls during the run time. Initially the page should contain single row(column1: combo box, colomn2: text box, column3: combo box and colomn4: button). If i...
1
by: Chezza | last post by:
Hi All, Thanks to those that have helped me before. It’s been a couple of weeks since I posted (I can only play with this during my spare time at work) so here’s the set up again- we receive...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.