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. Windows Forms
  4. Control Binding of a bool isn't updating

Control Binding of a bool isn't updating

Scheduled Pinned Locked Moved Windows Forms
questionwpfwcfhelptutorial
3 Posts 3 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.
  • T Offline
    T Offline
    TimmL
    wrote on last edited by
    #1

    hi, I want to bind a bool property of my class to the "Enabled" property of a control, but when I change my bool property, the enabled state of my control isn't changing, here an example // bool Property private bool boolValue = false; public bool BoolValue { get { return boolValue; } set { boolValue = value; } } // binding button1.DataBindings.Add("Enabled", this, "BoolValue", false, DataSourceUpdateMode.OnPropertyChanged); // later in code BoolValue = true; // enabled state of my control isn't changing How can I solve this problem? Regards, timm

    R D 2 Replies Last reply
    0
    • T TimmL

      hi, I want to bind a bool property of my class to the "Enabled" property of a control, but when I change my bool property, the enabled state of my control isn't changing, here an example // bool Property private bool boolValue = false; public bool BoolValue { get { return boolValue; } set { boolValue = value; } } // binding button1.DataBindings.Add("Enabled", this, "BoolValue", false, DataSourceUpdateMode.OnPropertyChanged); // later in code BoolValue = true; // enabled state of my control isn't changing How can I solve this problem? Regards, timm

      R Offline
      R Offline
      Richard Blythe
      wrote on last edited by
      #2

      The "DataSourceUpdateMode.OnPropertyChanged" is a flag that sends button1's "Enabled" value to the current record's "BoolValue" field. It does not tell the datasource to send updates to the control. What you need to do is force the binding context of the button to update it's index. This will cause: button1 to read the changed value.

      The mind is like a parachute. It doesn’t work unless it’s open.

      1 Reply Last reply
      0
      • T TimmL

        hi, I want to bind a bool property of my class to the "Enabled" property of a control, but when I change my bool property, the enabled state of my control isn't changing, here an example // bool Property private bool boolValue = false; public bool BoolValue { get { return boolValue; } set { boolValue = value; } } // binding button1.DataBindings.Add("Enabled", this, "BoolValue", false, DataSourceUpdateMode.OnPropertyChanged); // later in code BoolValue = true; // enabled state of my control isn't changing How can I solve this problem? Regards, timm

        D Offline
        D Offline
        darkelv
        wrote on last edited by
        #3

        You'll need to implement the OnBoolValueChanged event or OnPropertyChanged after the boolValue = value assignment. http://krisvandermotten.wordpress.com/2006/10/19/properties-with-property-changed-event/[^] http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/1e742062-bf41-48cf-bd2f-54bdc9c5b78d[^] Personally I prefer the OnXXXChanged because I'd rather not write a gigantic switch in the OnPropertyChanged handler.

        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