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.

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

plz tell me the procedure to do that...

oke..
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
to
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

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
        Next

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 + ")")
Next

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.