variable value shown to label text

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kenneth6
    New Member
    • Mar 2007
    • 79

    variable value shown to label text

    In c++ Windows Form App, how to show a variable value to the label text and update immediately?
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Not being a Windows Forms person, maybe you could explain this a little further. I am confused by the phrase show a variable value to the label text .

    Do you have a code snippet?

    Comment

    • kenneth6
      New Member
      • Mar 2007
      • 79

      #3
      Originally posted by weaknessforcats
      Not being a Windows Forms person, maybe you could explain this a little further. I am confused by the phrase show a variable value to the label text .

      Do you have a code snippet?
      if, in the constructor, i initialize a variable say "int abcNumber=0;" and the int type data will be changed some time during run-time, in the windows form, i wanna that int type data to be shown on the GUI. when the int variable changed inside the code, i wanna the chnaged value to be updated in the GUI. how to do that??

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        In C++ you would use an Observer. This is a desing pattern (see Design Patterns Erich Gamma et all Addison Wesley 1994).

        The pattern has you implement a Notify() method so that when the vaalue in the code changes Notify() is called. That Notify() can broadcast to any Observer objects that the vaue has changed. You watch the Observer object in your GUI and when it reports the change, then you can report the chnage in the GUI.

        Have a look.

        Comment

        Working...