日期:2014-05-18  浏览次数:20757 次

winform关闭窗体前判断是否有修改
我的form里有动态生成的button还有背景图。
如button的point(x,y)或者width和height有变化,则form提示已修改请保存,如果button和背景图都无改变,则直接关闭。
我知道是设置一个bool变量来判断,但是我不清楚怎么去判断point(x,y)或者width,height前后值改变了,怎么跟这个bool值关联起来。
因为button能动态生成多个,所以我想在里面做个for循环,做遍历。
刚接触C#,不懂得bool的用法,望高手不吝赐教。。。
http://topic.csdn.net/u/20100819/17/5a70d3f9-63be-42fc-ba9f-a68667fb4d48.html看过这个帖子,但是不知道如果前后值改变了怎么跟bool值关联上。。

------解决方案--------------------
1.生成button后 记录button的point或者width、height 假设定义一个变量记录宽度int width=20

2.关闭窗体时 再获取一次button的point或者width、height 定义一个变量记录宽度int width1=button.width

3. bool isChange=(width==width1);

------解决方案--------------------
做一个变量,在你所有改变属性的地方,对变量做标记
或者你看看INotifyPropertyChanging