Results 1 to 3 of 3

Thread: [RESOLVED] Binding a textbox to an array

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2006
    Location
    Local
    Posts
    112

    Resolved [RESOLVED] Binding a textbox to an array

    I would appreciate any help with the following.....
    Code:
           'Initialize an array
            Dim myArray() As String = {"One", "Two", "Three"}
    
            'as expected the text property of Textbox1 displays "One"
            TextBox1.DataBindings.Add("Text", myArray(0), "")
    
            ' subsequently myArray is modified but Textbox1 still displays "One"
            myArray(0) = "Four"
    How do I get Textbox1.text to display the new value in myArray(0)?

    Thanks
    Microsoft Visual Basic 2008

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Binding a textbox to an array

    You would either have to call the ReadValue method of your Binding or else use a BindingList in the first place instead of an array, in which case you can call ResetItem or ResetBindings.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2006
    Location
    Local
    Posts
    112

    Re: Binding a textbox to an array

    Thanks very much.
    BindingList works perfectly.
    Microsoft Visual Basic 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width