469,934 Members | 1,965 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

combo box

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.
--
Joe C
Nov 16 '05 #1
8 2795
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" <CZ*****@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
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.
--
Joe C

Nov 16 '05 #2
CZERNAI wrote:
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.
-------------------------------------------

Hans Kesting
Nov 16 '05 #3
On 17/12/2004 CZERNAI wrote:
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.

--
Jeff Gaines Damerham Hampshire UK
Posted with XanaNews 1.16.5.2 http://www.wilsonc.demon.co.uk/delphi.htm
Nov 16 '05 #4
Thank you all for your help.
It is very much appreciated.

Joe C

"Mats-Lennart Hansson" wrote:
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" <CZ*****@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
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.
--
Joe C


Nov 16 '05 #5
Thanks for your help.
Very much appreciated

"Jeff Gaines" wrote:
On 17/12/2004 CZERNAI wrote:
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.

--
Jeff Gaines Damerham Hampshire UK
Posted with XanaNews 1.16.5.2 http://www.wilsonc.demon.co.uk/delphi.htm

Nov 16 '05 #6
Thanks for your help
It is much appreciated.
JOe C
"Hans Kesting" wrote:
CZERNAI wrote:
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.
-------------------------------------------

Hans Kesting

Nov 16 '05 #7
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #8
Thank's for your reply. Itis much appreciated.
My problem is solved.
Joe c

"Ravichandran J.V." wrote:
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by vgrssrtrs | last post: by
4 posts views Thread by Heather | last post: by
6 posts views Thread by Support4John | last post: by
2 posts views Thread by Jeff Mason | last post: by
2 posts views Thread by kiranmn75 | last post: by
2 posts views Thread by biganthony via AccessMonster.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.