I have a form with multiple combo boxes and text boxes making an invoice.. I have the combo boxes linked to my database and I want each selection to fill a different textbox. The comboboxes fill on form load... How can I fill the textbox with the selected index from the combobox? Any help will do. I am using Visual Studio 2010 in .net not C#

first, I want to clarify that visual studio 2010 is IDE application. Since vs2010 is a .net framework, you can use any programming language you want that is included within .net. maybe, your trying to say that you are using vb.net?

yes I'm using vb.net not any of the other programs in visual studio..I had said that about C# because sometimes I get relpries thinking I am so I wnted to clarify I'm using VB.Net..thank you

ok. I'm also working with the same scenario, I'll share it with you later.

the hardest part I have is all the combo boxes are linked to the same table and with each selected needs to go to a seperate txtbox. Combo Boxes are ID number and the txt Boxes are Description & cost. Whatever you can come up with will be helpful. I did come up with a 2 line coed but it still changes everything else...grrr

Private Sub ComboBox6_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox6.SelectedIndexChanged

        'fills selected text box with selected row from database

        IncomeCodesBindingSource1.CurrencyManager.Position = ComboBox6.SelectedIndex

       txtDescription1.Text = ComboBox6.SelectedValue("Invoice_Description")



    End Sub

the information that you are using to fill the text boxes, where are they comming from?

from the database selected row where it says (Invoice_Description) in the colum of that row

Just to clarify, when you say

all the combo boxes are linked to the same table

that means you have a unique datatable as data source for all the comboboxes?
Or you are filling the combobox items using a datareader?

In the first scenario when you select an item in one of the comboboxes, the current record in the datatable will point the the one selected.
Then all the other selected items are bound to the same current record in the datatable. I would suggest to have separate datatables, one for each combobox.

Hope this helps

I'll try this but will it work when all the combo boxes are set to the same datasource or bindingsource?

You need separate datasources / binding sources for each combo.

ok I got that setup now I'm being stupid. would you set in up this way?

Private Sub CBIC_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CBIC.SelectedIndexChanged

 IncomeCodesBindingSource = CBIC.SelectedValue

        TxtDescription.Text = CBIC.SelectedValue("Invoice_Description")


    End Sub

IMO to fill the valid text you do not need the line

IncomeCodesBindingSource = CBIC.SelectedValue

ok but on my selection of each combo box I need to fill the text of 2 textboxes both being filled with different colums of the row selected

I have a form with multiple combo boxes and text boxes making an invoice.. I have the combo boxes linked to my database and I want each selection to fill a different textbox. The comboboxes fill on form load... How can I fill the textbox with the selected index from the combobox? Any help will do. I am using Visual Studio 2010 in .net not C#

I suggest you to fill DataTables. Each dataTable for each comboBox (so you will have data seperated). Then you use DataBinding, which will be based on each comboBox selection.

could you be so kind as to give me an example please?

Actually I am lost. Do you need an example of what?

Please be so kind to consider putting all your code here and clarify wich are your expected behaviours, the expected results and the current ones.

Many thanks

need an example of how to have multiple compboboxes all linked to the same dataset/bindingsouce and place selected description in selected texbox.

Private Sub ComboBox6_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox6.SelectedIndexChanged
        'Choose selected row from database and place Discription in description textbox from Description Collum
        IncomeCodesBindingSource1 = ComboBox6.SelectedValue
        txtDescription1.Text = ComboBox6.SelectedValue("Invoice_Description")

    End Sub


    Private Sub CBIC_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CBIC.SelectedIndexChanged
        'Choose selected row from database and place Discription in description textbox from Description Collum
        IncomeCodesBindingSource = CBIC.SelectedValue
        TxtDescription.Text = CBIC.SelectedValue("Invoice_Description")

    End Sub

    Private Sub ComboBox5_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox5.SelectedIndexChanged
        'Choose selected row from database and place Discription in description textbox from Description Collum
        Income_CodesTableAdapter2 = ComboBox5.SelectedValue
        TxtDescription2.Text = ComboBox5.SelectedValue("Invoice_Description")

    End Sub

I used tab control in vb.net. when i click tab automatically number will show in textbox from database number+1. which is already stored number + 1.
for example already database invoice number stored EC000. when i click tab show the number EC001.
Am used MS-ACCESS databse. please reply with code..

commented: Is not a good idea to fill a thread with new questions. Please start a distinct one. -2

the code is above here and I have someone working on it. When I select from the combo box it places the description in the textbox but when I select the next combo boxe it changes the first description and doesn't place the second in the second textbox

@twalton42,

Mitja and I always said that you need to create separated, independent, data sources for each combo box, but you never show us how you did that.

The code you post above is not enough to see what you are doing, so we can not help further unless you create a zip with all your project and post it here.

Sorry for the inconvenience.

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.