-
November 6th, 2008, 04:32 AM
#1
Adding ComboBox Values At Run Time
how to add values in combobox at run time in VB.NET????
-
November 6th, 2008, 05:59 AM
#2
Re: hey anyone help me out plz
Welcome to the forums
Simply use :
Code:
YourComboBoxName.Items.Add("Whatever Value(s)")
You could also use the Insert method, to add an item at a specific place ( index ) in the Combo.
-
November 7th, 2008, 01:25 AM
#3
Re: hey anyone help me out plz
Originally Posted by HanneSThEGreaT
Welcome to the forums
Simply use :
Code:
YourComboBoxName.Items.Add("Whatever Value(s)")
You could also use the Insert method, to add an item at a specific place ( index ) in the Combo.
sir actually i want to add items in combobx at run time..when i run my form..Through your code il be only able to get fixed values which i have added in the code
-
November 7th, 2008, 01:44 AM
#4
Re: hey anyone help me out plz
Do you mean you have dynamic values ( for example an array ) that you want to add to the combobox ¿
Can you please explain more on what values you want to add, what you want to do ¿
It would still be using the same principal as this code in any case.
-
November 7th, 2008, 02:39 AM
#5
Re: Adding ComboBox Values At Run Time
yes i have dynamic values the user would be entering them at run time.i want to add departement names through the combobox.i had previosly added values using display value and display member but every time i had to debug in order to show the newly added item in the combobx
-
November 7th, 2008, 02:40 AM
#6
Re: hey anyone help me out plz
Originally Posted by HanneSThEGreaT
Do you mean you have dynamic values ( for example an array ) that you want to add to the combobox ¿
Can you please explain more on what values you want to add, what you want to do ¿
It would still be using the same principal as this code in any case.
yes i have dynamic values the user would be entering them at run time.i want to add departement names through the combobox.i had previosly added values using display value and display member but every time i had to debug in order to show the newly added item in the combobx
-
November 7th, 2008, 02:53 AM
#7
Re: hey anyone help me out plz
I don't understand this situation you are sitting with kriti
This code is quite simple, why was there a need to debug ¿
What precise code did you use ¿
Let me see. the user types in a department name inside a Textbox, during run time - is that correct ¿
If it was indeed entered into a textbox, you could perhaps use the textBox's Leave / LostFocus event, to add the entered item into the combobox.
Let us presume your textBox is named txtDeptName and your combobox is named cbodeptname
All you need to do ( in the Leave / LostFocus event of txtDeptName is :
Code:
cboDeptName.Items.Add(txtDeptName.Text)
-
November 7th, 2008, 04:03 AM
#8
Re: hey anyone help me out plz
Originally Posted by HanneSThEGreaT
I don't understand this situation you are sitting with kriti
This code is quite simple, why was there a need to debug ¿
What precise code did you use ¿
Let me see. the user types in a department name inside a Textbox, during run time - is that correct ¿
If it was indeed entered into a textbox, you could perhaps use the textBox's Leave / LostFocus event, to add the entered item into the combobox.
Let us presume your textBox is named txtDeptName and your combobox is named cbodeptname
All you need to do ( in the Leave / LostFocus event of txtDeptName is :
Code:
cboDeptName.Items.Add(txtDeptName.Text)
yes the user enters through the text box and the same value is getting stored in the combobox ..but when i again run the program the combobox is not showing the values entered previously
-
November 7th, 2008, 04:19 AM
#9
Re: hey anyone help me out plz
Originally Posted by kriti
but when i again run the program the combobox is not showing the values entered previously
Does this mean you are exiting the program / unloading the form ¿
So, are you looking for a way to permanently store the department names entered, and read from that list.
Is this application using a database or something ¿
-
November 7th, 2008, 04:23 AM
#10
Re: hey anyone help me out plz
Originally Posted by HanneSThEGreaT
I don't understand this situation you are sitting with kriti
This code is quite simple, why was there a need to debug ¿
What precise code did you use ¿
Let me see. the user types in a department name inside a Textbox, during run time - is that correct ¿
If it was indeed entered into a textbox, you could perhaps use the textBox's Leave / LostFocus event, to add the entered item into the combobox.
Let us presume your textBox is named txtDeptName and your combobox is named cbodeptname
All you need to do ( in the Leave / LostFocus event of txtDeptName is :
Code:
cboDeptName.Items.Add(txtDeptName.Text)
sir plz reply>>>>
-
November 7th, 2008, 04:41 AM
#11
Re: hey anyone help me out plz
Originally Posted by HanneSThEGreaT
Does this mean you are exiting the program / unloading the form ¿
So, are you looking for a way to permanently store the department names entered, and read from that list.
Is this application using a database or something ¿
yes sir i want to see the dept names in the combobox which are entered through the textbox permanetly every time i unload the form.do reply with the solution.
-
November 7th, 2008, 04:43 AM
#12
Re: hey anyone help me out plz
Originally Posted by kriti
yes sir i want to see the dept names in the combobox which are entered through the textbox permanetly every time i unload the form.do reply with the solution.
yes iam using the database
-
November 7th, 2008, 04:51 AM
#13
Re: hey anyone help me out plz
Thanx for finally telling us that you are using a database. If this was said in your first post, we'd have made much more progress by now.
Are the connections set up, have you connected any of the controls to their appropriate fields, from the database, or haven't you connected anything yet ¿
have you any knowledge of ADO.NET ¿
-
November 7th, 2008, 04:56 AM
#14
Re: hey anyone help me out plz
Originally Posted by HanneSThEGreaT
Thanx for finally telling us that you are using a database. If this was said in your first post, we'd have made much more progress by now.
Are the connections set up, have you connected any of the controls to their appropriate fields, from the database, or haven't you connected anything yet ¿
have you any knowledge of ADO.NET ¿
iam sorry new to everything...yes all my connectins with the database are made.just want this functionality...iam able to save the values entered in the textbox in the database.
-
November 7th, 2008, 04:59 AM
#15
Re: hey anyone help me out plz
Originally Posted by kriti
iam sorry new to everything...yes all my connectins with the database are made.just want this functionality...iam able to save the values entered in the textbox in the database.
yes iam familiar with ADO.NET
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|