In c++ Windows Form App, how to show a variable value to the label text and update immediately?
variable value shown to label text
Collapse
X
-
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??Originally posted by weaknessforcatsNot 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
-
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
Comment