combo box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
Am new to programming and to this process of asking questions. I believe I
have read all the threads concerning combo box questions but haven't found an
answer to my problem.

I am using "combobox.items.add(combobox.text)" to add an item to the
collection
of the combo box. When the program runs I can see the new item in the combo
box (hi-lited) but when i close the form the new item doesn't stay in the
collection.
I put some items in the CB initially through the collection property.

I have used both the drop down and simple styles but neither retain the new
item in the collection.

In additioin to to reading every help item concerning combo boxes in vb.net,
I have looked at every book I could find in the book store to see if there
was additional code I need to use to save the item in the collection but
can't seem to find anything.


I have tried doing this under the "selected index event" as well as the "key
press" event. I even tried using a button click event.

At first I had the combo box in a group box and then moved it out onto the
form.
I even set up a new solution and only had a combo box on the form but had
the same problem.

I have a suspension that some setting on a form property or another control
or on my set up of vb net is is causing this but I have run out of ideas
where to look.

If this turns out to be something ridiculously simple I apologize, but I do
need help.
Any ideas.
Thans.
 
Hi,
The items you add during design time is compiled into the assembly when you
build the program. Those items you add during runtime is not saved into the
assembly and will therefor not remain when you restart your program.

To achieve what you want you need to store the data externally, perhaps in a
textfile or the registry. Then you read this data and populate the combobox
during form_load.

/Mats-Lennart
 
CZERNAI said:
Hi
Am new to programming and to this process of asking questions. I
believe I have read all the threads concerning combo box questions
but haven't found an answer to my problem.

I am using "combobox.items.add(combobox.text)" to add an item to the
collection
of the combo box. When the program runs I can see the new item in the
combo box (hi-lited) but when i close the form the new item doesn't
stay in the collection.
I put some items in the CB initially through the collection property.

I have used both the drop down and simple styles but neither retain
the new item in the collection.

In additioin to to reading every help item concerning combo boxes in
vb.net, I have looked at every book I could find in the book store to
see if there was additional code I need to use to save the item in
the collection but can't seem to find anything.


I have tried doing this under the "selected index event" as well as
the "key press" event. I even tried using a button click event.

At first I had the combo box in a group box and then moved it out
onto the form.
I even set up a new solution and only had a combo box on the form but
had the same problem.

I have a suspension that some setting on a form property or another
control or on my set up of vb net is is causing this but I have run
out of ideas where to look.

If this turns out to be something ridiculously simple I apologize,
but I do need help.
Any ideas.
Thans.

Exactly what do you mean with "close the form"?
When and how do you see that the added value is not there?

A form is just a class (with a visual representation). When you create
a new instance of a class, it will not have any values of some other instance
of that class.

--------------------------------------------
MyForm theForm = new MyForm();
theForm.Show();
theForm.Hide();
theForm.Show(); <-- shows the *same* form again with the *same* values
-------------------------------------------
MyForm theForm = new MyForm();
theForm.Show();
theForm.Hide();
theForm = new MyForm(); <-- creates a *new* instance
theForm.Show(); <-- as it is a different instance, it might show different values.
 
Hi
Am new to programming and to this process of asking questions. I
believe I have read all the threads concerning combo box questions
but haven't found an answer to my problem.

I am using "combobox.items.add(combobox.text)" to add an item to the
collection
of the combo box. When the program runs I can see the new item in the
combo box (hi-lited) but when i close the form the new item doesn't
stay in the collection.
I put some items in the CB initially through the collection property.

I have used both the drop down and simple styles but neither retain
the new item in the collection.

The ComboBox won't store these items when you close the app.

If you want to store them you will have to trap the form's closing
event, write the items out to a file of some sort and then re-load them
when you run the app again.
 
Thanks for your help.
Very much appreciated

Jeff Gaines said:
The ComboBox won't store these items when you close the app.

If you want to store them you will have to trap the form's closing
event, write the items out to a file of some sort and then re-load them
when you run the app again.
 
I am sure you are populating the combo in the load event and before
closing the form, you are not updating the data source of the combo with
the updated items.

Please post your code for more clarity.

with regards,


J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandran+J.V.&cob=aspnetpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID=P3966388&BN=999&PN=2
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com
 
Back
Top