Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. ApplicationSettings property binding in TextBox with integer value

ApplicationSettings property binding in TextBox with integer value

Scheduled Pinned Locked Moved C#
wpfwcftutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chesnokov Yuriy
    wrote on last edited by
    #1

    How to relate TextBox.Text field with integer value in application settings? If e.g. Settings.Default.MyValue is not a string it is not possible to assign it to controls returning string in applicationsettings property binding property.

    Чесноков

    M 1 Reply Last reply
    0
    • C Chesnokov Yuriy

      How to relate TextBox.Text field with integer value in application settings? If e.g. Settings.Default.MyValue is not a string it is not possible to assign it to controls returning string in applicationsettings property binding property.

      Чесноков

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      With Windows Forms? The conversion should be done implicitly... This works on an integer app setting called "MyAppSetting"...

          private void On\_FormLoad(object sender, EventArgs e)
          {
              Binding binding = new Binding("Text", MyAppNamespace.Properties.Settings.Default, "MyAppSetting", true, DataSourceUpdateMode.OnPropertyChanged);
              this.textBox1.DataBindings.Add(binding);
          }
      

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      modified on Thursday, May 12, 2011 2:00 PM

      C 1 Reply Last reply
      0
      • M Mark Salsbery

        With Windows Forms? The conversion should be done implicitly... This works on an integer app setting called "MyAppSetting"...

            private void On\_FormLoad(object sender, EventArgs e)
            {
                Binding binding = new Binding("Text", MyAppNamespace.Properties.Settings.Default, "MyAppSetting", true, DataSourceUpdateMode.OnPropertyChanged);
                this.textBox1.DataBindings.Add(binding);
            }
        

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        modified on Thursday, May 12, 2011 2:00 PM

        C Offline
        C Offline
        Chesnokov Yuriy
        wrote on last edited by
        #3

        Yes, in windows forms. I have int MyAppSetting in application settings defined. It is not possible to set it in ApplicationSettings property binding for TextBox.Text property. Only if MyAppSetting is a string that can be setup in the IDE and I have to query it as Int32.Parse(MyAppNamespace.Properties.Settings.Default.MyAppSetting). Did you mean explicitly? The only solution to add the logic in code?

        Чесноков

        M 1 Reply Last reply
        0
        • C Chesnokov Yuriy

          Yes, in windows forms. I have int MyAppSetting in application settings defined. It is not possible to set it in ApplicationSettings property binding for TextBox.Text property. Only if MyAppSetting is a string that can be setup in the IDE and I have to query it as Int32.Parse(MyAppNamespace.Properties.Settings.Default.MyAppSetting). Did you mean explicitly? The only solution to add the logic in code?

          Чесноков

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          I'm not a forms programmer, but I see that using the VS10 designer properties window to add the binding adds a line of code that initializes the textbox.Text property, and that line won't compile. Funny it doesn't even need that line...bug or feature? So it looks to me like the binding needs to be added by hand, which I tested and it works fine.

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups