hi frnds ,
i have a combobox containing countries name and their codes like INDIA:CNT001
then i have a textbox that store the code of country i.e CNT001(fetching from database)
Now i want to match that code with the combobox code so that the combobox is set to that item when i click a button.
i m using vb.net and sql server as database.

5 Years
Discussion Span
Last Post by NewUserVB.Net

Goodmorning, this is very simple, you have only to add a Data BindingSource, and a Data BindingNavigator, connect them, and try it... if it doesn't worked then post and i will find one other solution. Remember to connect the combobox and textbox with Data BindingSource

Edited by NewUserVB.Net: n/a


so go to the Toolbox Panel and add Binding Source in DATA Collapsible Panel, then go to Proprty Panel and modify in Data the property:
DataSource: None
click on that and click on "Add Project Data Source..."
then you have many option, click next, next, New connection, Browse, *Load the Database File*, Ok, Next, Yes, Finish, *select all tables*, Finish, and you have integrated the database in your project.
See the images that I attached to help you....
Now select the combobox and modify his property
Data Source: None
select the table and connect the combobox with the database
Re do same thing with the textbox,
Now your Database is connected with Combobox and Textbox.
You can do this with everything, like label text, listbox items, progressbar value, everything....
Now add Data BindingNavigator, and modify his property:
Binding Source: None
Binding Source: and here the name of the BindingSource
it will gives you suggestion.
select the bindingsource
and try it!
If you need more help wait some time, and i will make a video tutorial for you... but i hope to be helpful here... but if you need for help post.. no problem

Attachments Propery_to_modify.png 20.27 KB Step10.png 24.24 KB Step1.png 75.04 KB Step2.png 77.43 KB Step3.png 85.05 KB Step4.png 111.1 KB Step5.png 115.57 KB Step6.png 79.02 KB Step7.png 107.34 KB Step8.png 79.21 KB Step9.png 79.91 KB

thnxs sir for ur concern ...but what i actually want to do will be clear wen u c the image tht i hav attached.i hav done som coding of my own but it seems not working.

Dim j As String = TxtCategory.Text.Substring(3, 3).ToString
        For k As Integer = 1 To CbCategory.Items.Count
           Dim q As String = (CbCategory.Items(k).ToString)
            If q = Microsoft.VisualBasic.Right(CbCategory.Text, 3) Then
               CbCategory.SelectedIndex = k
           End If
Attachments Capture.PNG 2.42 KB

ah ok, so i suggest you to make the database with 2 column.
first: the Title of the product
second: the ID number of the product
now you have to delete the connection between combobox and the dtatasource (but don't delete any other connection) and write this code in Form Load:

For each Item In WriteHereDatabaseName.WriteHereDatabaseTableName
      combobox1.items.add(Item.NoCProduct + " (" + Item.NocProductID + ")")

modify the connection between the textbox and datasource to the NocProductID
WriteHereDatabaseName = title of the database
WriteHereDatabaseTableName = title of the table in the database
NoCProduct = Name Of Column of Product
NoCProductID = Name Of column of Product ID

try now

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.