Detecting if variables have been changed
I have a main form that shows another options dialog. Once the options form has been changed, I want properties on the main form to be changed as a result. However, how could I detect if the variables have been changed? BTW, I am sharing the vars in a module. I considered making it detect the vars once the user moves his mouse over the main form, but I want to know if there is a better way. Would a timer be better or is there an even better way? Thanks!
Re: Detecting if variables have been changed
I'm confused.. If you have routines in place to change the data, shouldn't they also be able to set the properties elsewhere? Is there a specific type of variable or scenario giving you trouble? Most of the form objects have a .changed or .selectedindexchanged event you can handle..
Bill
Re: Detecting if variables have been changed
I am not just setting properties on the main form. For example, if I want the form to become topmost then immediately not topmost, i had:
VB Code:
If Vars.popup = "True" Or System.Configuration.ConfigurationSettings.AppSettings("configpopup") = True Then
Me.TopMost = True
Me.TopMost = False
End If
Re: Detecting if variables have been changed
Unless you keep two copies of the settings then you aren't to know whether they've changed. Why don't you just run through all the settings and set whatever properties they correspond to accordingly. That way the ones that have changed will be reflected and the ones that haven't will just stay as they are. The alternative would be to create events attached to those properties, but that's probably more effort than it's worth.
Re: Detecting if variables have been changed
Quote:
Originally Posted by conipto
I'm confused.. If you have routines in place to change the data, shouldn't they also be able to set the properties elsewhere? Is there a specific type of variable or scenario giving you trouble? Most of the form objects have a .changed or .selectedindexchanged event you can handle..
Bill
Pardon me if i am incorrect here, but isn't the task ou are performing here redundant?
why are you making your form topmost, and then not topmost?
Is this to bring it to the front of the screen but not remain covering everything up? because i do believe .show performs this same action of bring the form to the top, i think you can also use .focus as well.
Re: Detecting if variables have been changed
No pal,...
.show just shows the form..if u use .show again,it doesnt bring the form on top :)
Re: Detecting if variables have been changed
Quote:
Originally Posted by uniquegodwin
No pal,...
.show just shows the form..if u use .show again,it doesnt bring the form on top :)
it appears you are correct. the only other way is with an API Call
nevermind then.
Re: Detecting if variables have been changed
How about if you made those variables private members of a class, then expose them as properties. Add a variable to the class along the lines of ImChanged, and set it when the Set part of the property is run.
There are two problems I see with this, which may not be problems for you:
1) If the property changes from A to B, then changes from B to A, the property will remain effectively unchanged, but the class will not remember that unless it needs to be designed to always remember that the property started at A.
2) I can't remember the other issue, but I'm sure there was one.
Re: Detecting if variables have been changed
Quote:
Originally Posted by uniquegodwin
No pal,...
.show just shows the form..if u use .show again,it doesnt bring the form on top :)
If you want to bring a form to the front you call Activate on it.