Results 1 to 5 of 5

Thread: [RESOLVED] [2005] Binding variables to controls

  1. #1

    Thread Starter
    Hyperactive Member ZaNi's Avatar
    Join Date
    Jun 2006
    Location
    Australia
    Posts
    360

    Resolved [RESOLVED] [2005] Binding variables to controls

    A thought just occured to me. I don't understand what binding's are supposed to handle. Could they be used in such a way that I don't need to set my background variables to be equal to whats displayed in a control manually?

    What I mean is: can I use bindings to automatically set the value of one of my variables to the value of a control (eg mystring = TextBox1.Text, except automatically)?
    * Don't limit yourself to sanity
    * I'd rather be optimistic and naive than pessimistic and right
    * Ask good questions, get good answers.

    My Codebank submissions:
    How to write one rountine to handle many events
    Accessing and Using variables across multiple forms
    Printing/Previewing a form or control

    Links I've "borrowed" from other people:
    vbdotnetboy - Awesome site for tips

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339

    Re: [2005] Binding variables to controls

    Yes you can do that if your mystring is a bindable object. Most controls can bind to objects or data although objects may need to implement certain binding interfaces to work right.

  3. #3

    Thread Starter
    Hyperactive Member ZaNi's Avatar
    Join Date
    Jun 2006
    Location
    Australia
    Posts
    360

    Re: [2005] Binding variables to controls

    So if I had a NumericUpDown box I wanted to bind to a single or an integer, or a TextBox I wanted to bind to a string, would that work?
    * Don't limit yourself to sanity
    * I'd rather be optimistic and naive than pessimistic and right
    * Ask good questions, get good answers.

    My Codebank submissions:
    How to write one rountine to handle many events
    Accessing and Using variables across multiple forms
    Printing/Previewing a form or control

    Links I've "borrowed" from other people:
    vbdotnetboy - Awesome site for tips

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

    Re: [2005] Binding variables to controls

    That's EXACTLY what data-binding is. You bind the value(s) in a data store to a value displayed in a control. You can fine tune the behaviour of a Binding in .NET 2.0 but the basic idea is that when you update one the other reflects that change. Probably the most common data-binding is a DataTable to a DataGridView, where any updates the user makes in the grid are automatically propagated to the table. That's called complex data-binding, when you set a DataSource property. Using simple data-binding you can basically bind any property of any control to any suitable object. You should read about the Binding class for more information.
    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

  5. #5

    Thread Starter
    Hyperactive Member ZaNi's Avatar
    Join Date
    Jun 2006
    Location
    Australia
    Posts
    360

    Re: [2005] Binding variables to controls

    I suspected that, but that you for stating it clearly for me, jmcilhinney. Thank you too Edneeis. I think I can figure the rest out myself now.
    * Don't limit yourself to sanity
    * I'd rather be optimistic and naive than pessimistic and right
    * Ask good questions, get good answers.

    My Codebank submissions:
    How to write one rountine to handle many events
    Accessing and Using variables across multiple forms
    Printing/Previewing a form or control

    Links I've "borrowed" from other people:
    vbdotnetboy - Awesome site for tips

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