binding textbox to datasource in code(run time)

Hi, i'm trying to figure out how to bind a text box with datesource control in code so that it could be bounded in run time. i tried this code:

Dim myBind As System.Windows.Forms.Binding = New Binding("Text", Me.DbDataSet1.Customers, "FirstName")

Me.TextBox1.DataBindings.Add(myBind)

but it doesnt work

is there any body have any help



Answer this question

binding textbox to datasource in code(run time)

  • #DressedMan

    Hi, Thanks for your help Your code works fine.

    if possible please try to help me with my other question.

    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1005265&SiteID=1

    here in this link. Thanks in advance


  • Symon Buck

    Hi,

    Try using a binding source object:

    Me.TextBox1.DataBindings.Add( New Binding("Text", Me.CustomersBindingSource, "FirstName") )

    Charles


  • Butters_Stotch

    vien11 wrote:
    but it doesnt work

    What exactly doesn't work You're binding TextBox1 to a FirstName column in a Customers datatable instance. If this instance is populated with the data, the textbox should display the appropriate value. What's happening in your case

    Andrej



  • binding textbox to datasource in code(run time)