Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combobox configuration in VS2008

Status
Not open for further replies.

KiaKia

Programmer
Mar 30, 2008
59
0
0
US
HI,
I have recently switched from VBA to VB in VS2008 and am wondering to know if I can configure a combo box so that it is not limited to the items of it's bounded data source.

It would be also cool if there is a way to automatically add the new data ( which is not already in the list) to the combobox list as the user types them in the combo box.

Any comment will be highly appreciated.

 
If it's bound to a DataTable, you can add new DataRows through code to the DataTable. However, be sure you don't have these rows pushed back to the database unless that would be intended behavior.
 
Thanks ReverGuy,
My first problem is that when I add a combo box to my form and bound it to a data table, I am limited to choose from the items which are present in that data table. I am not able to type in texts to my Combo_box.
Would you please help me more on that?

Kia

 
I'm not sure. You might want to try looping through a DataReader and adding string items based on the DataReader to the ComboBox instead of data-binding it.
 
I do not know any thing about datareaders.
What is the difference? whould you please explain it for me.

Thanks,
Kia
 
datareader is nothing but one object will hold the data's
and simply as per our style can say one variable will hold the table contents.

Dim con As New SqlConnection("Data Source=1.1.1.2; initial Catalog=Emp_Management; User Id=sa; Password=123456789")

Dim cmd1 As New SqlCommand("Select * from emp_professions", con)

Dim dr1 As SqlDataReader

cmd1.Connection.Open()
dr1 = cmd1.ExecuteReader
While dr1.Read
treecombo.mylistview.Items.Add(dr1(0))
treecombo.mylistview.Items(treecombo.mylistview.Items.Count - 1).SubItems.Add(dr1(1))
End While

cmd1.Connection.Close()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top