databind from combo box to texboxes

select data from combo box and display in textboxes

Page 1 of 1

2 Replies - 4347 Views - Last Post: 16 October 2010 - 05:20 AM Rate Topic: -----

#1 Suryati Akz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 26-February 10

databind from combo box to texboxes

Posted 16 October 2010 - 01:11 AM

after listing the data from data base to combo box, i would like bind the chosen data from combo box to text box

 'bind from combo box to textbox
        Dim ConString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Car Rental Data\Mutiata Company Car Rental System1.mdb"
        Try
            'open connection
            cn = New OleDbConnection(ConString)
            cn.Open()

        Catch ex As Exception
            cm = New OleDbCommand("SELECT * FROM CustomerDetails;", cn)

            'data row
            Dim SQLString As String = "SELECT * FROM CustomerDetails "
            da = New OleDbDataAdapter(SQLString, cn)

            'instantiate dataset
            ds = New DataSet()
            'get collecton
            'between source and data
            da.TableMappings.Add("Table", "CustomerDetails")

            'retrieve by select command
            Me.CustomerDetailsTableAdapter.Fill(Me.Mutiata_Company_Car_Rental_System1DataSet.CustomerDetails)

            'dataviewmanager
            Dim dviewmanager As DataViewManager
            dviewmanager = ds.DefaultViewManager
            combocust.DataSource = CustomerDetailsTableAdapter

            'choose table, display column
            combocust.DisplayMember = "CustomerDetails.I/C Number"

            combocust.DataSource = Mutiata_Company_Car_Rental_System1DataSet.Tables("CustomerDetails")
            combocust.DisplayMember = "I/C Number"
            combocust.ValueMember = "I/C Number"
            TextBox30.DataBindings.Add("Text", CustomerDetailsTableAdapter, "CustomerDetails.Name")
            TextBox29.DataBindings.Add("Text", CustomerDetailsTableAdapter, "CustomerDetails.I/C Number")
            TextBox28.DataBindings.Add("Text", CustomerDetailsTableAdapter, "CustomerDetails.Phone    Number")
            TextBox27.DataBindings.Add("Text", CustomerDetailsTableAdapter, "CustomerDetails.Address")
            TextBox26.DataBindings.Add("Text", CustomerDetailsTableAdapter, "CustomerDetails.Poscode")
            TextBox25.DataBindings.Add("Text", CustomerDetailsTableAdapter, "CustomerDetails.State")
            cn.Close()
        End Try 


i have try using this code to bind the data from combo box to textbox, but unsuccessful to display the data in textbox. Is there any code that i left behind?

Is This A Good Question/Topic? 0
  • +

Replies To: databind from combo box to texboxes

#2 TEH  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 29
  • View blog
  • Posts: 152
  • Joined: 30-January 08

Re: databind from combo box to texboxes

Posted 16 October 2010 - 01:41 AM

theres designer way to do that, it is:

    1.
  • click to your combobox
  • click + in databindings in properties
  • to text property select your bindingsource and column

    2. same things to textbox


and it should show selected value of combobox in textbox.

This post has been edited by TEH: 16 October 2010 - 01:41 AM

Was This Post Helpful? 0
  • +
  • -

#3 Suryati Akz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 26-February 10

Re: databind from combo box to texboxes

Posted 16 October 2010 - 05:20 AM

View PostTEH, on 16 October 2010 - 12:41 AM, said:

theres designer way to do that, it is:

    1.
  • click to your combobox
  • click + in databindings in properties
  • to text property select your bindingsource and column

    2. same things to textbox


and it should show selected value of combobox in textbox.

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1