Data binding to My.Settings

Discussion in 'Microsoft VB .NET' started by Bob Altman, Aug 3, 2006.

  1. Bob Altman

    Bob Altman Guest

    How do I bind a value from My.Settings to a property on a control on a
    Windows form?

    I've created a setting called My.Settings.Value1 of type String. Now I want
    to create a "Settings" dialog box that allows the user to view or change
    My.Settings.Value1.

    I added My.MySettings as a Data Source.
    I created a simple dialog box with Ok and Cancel buttons.
    I dragged Value1 from the Data Sources window to the form. The designer
    dutifully created a TextBox with its Text property wired to a BindingSource,
    plus a BindingNavigator (the purpose of which is a mystery to me).

    I run my application, display the dialog box, type something into the
    TextBox, and click the Ok button. In the Ok button's Click event handler,
    My.Settings.Value1 contains an empty string. (Yes I called
    MySettingsBindingSource.EndEdit before I examined the value of
    My.Settings.Value1.)

    Any suggestions? TIA!

    - Bob
     
    Bob Altman, Aug 3, 2006
    #1
    1. Advertisements

  2. Bob Altman

    Bob Altman Guest

    I stumbled across the answer in the latest issue of CoDe Magazine
    (http://www.code-magazine.com/Article.aspx?quickid=0607031). Simply select
    the control, and, in the properties window open the (Application Settings)
    property. Then click on the [...] button in the (Property Bindings)
    property.

    Apparently, trying to use the Data Source magic to create a binding doesn't
    work. Looks like a bug to me...

    - Bob

    "Bob Altman" <> wrote in message
    news:%...
    > How do I bind a value from My.Settings to a property on a control on a
    > Windows form?
    >
    > I've created a setting called My.Settings.Value1 of type String. Now I
    > want
    > to create a "Settings" dialog box that allows the user to view or change
    > My.Settings.Value1.
    >
    > I added My.MySettings as a Data Source.
    > I created a simple dialog box with Ok and Cancel buttons.
    > I dragged Value1 from the Data Sources window to the form. The designer
    > dutifully created a TextBox with its Text property wired to a
    > BindingSource,
    > plus a BindingNavigator (the purpose of which is a mystery to me).
    >
    > I run my application, display the dialog box, type something into the
    > TextBox, and click the Ok button. In the Ok button's Click event handler,
    > My.Settings.Value1 contains an empty string. (Yes I called
    > MySettingsBindingSource.EndEdit before I examined the value of
    > My.Settings.Value1.)
    >
    > Any suggestions? TIA!
    >
    > - Bob
    >
    >
     
    Bob Altman, Aug 3, 2006
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Lance Geeck

    Text Box and Data Binding Question

    Lance Geeck, Sep 5, 2003, in forum: Microsoft VB .NET
    Replies:
    0
    Views:
    258
    Lance Geeck
    Sep 5, 2003
  2. Frank Yamrick

    setting binding data

    Frank Yamrick, Sep 10, 2003, in forum: Microsoft VB .NET
    Replies:
    0
    Views:
    196
    Frank Yamrick
    Sep 10, 2003
  3. What-a-Tool

    ADO or ADOn't, binding data to an array?

    What-a-Tool, Sep 15, 2003, in forum: Microsoft VB .NET
    Replies:
    8
    Views:
    266
    Ravichandran J.V.
    Sep 17, 2003
  4. Ale K.

    Data Binding...?

    Ale K., Sep 26, 2003, in forum: Microsoft VB .NET
    Replies:
    1
    Views:
    167
    Lucas Tam
    Sep 26, 2003
  5. Tubs
    Replies:
    2
    Views:
    277
    Troy Stauffer
    Oct 16, 2003
  6. alan

    ListView Data Binding Error

    alan, Oct 20, 2003, in forum: Microsoft VB .NET
    Replies:
    0
    Views:
    430
  7. Guest

    Early Binding v.s. Late Binding

    Guest, Jan 19, 2004, in forum: Microsoft VB .NET
    Replies:
    13
    Views:
    2,360
    Jay B. Harlow [MVP - Outlook]
    Jan 19, 2004
  8. Mike
    Replies:
    0
    Views:
    461
Loading...