日期:2014-05-18 浏览次数:20965 次
<userPerference>
<controls>
<control id="button">
<properties>
<property name="ForeColor" value="Red" />
<property name="Size" value="100,40" />
<properties>
</control>
</controls>
</userPerference>
------解决方案--------------------
Tolgahan's Form Property Saver
https://secure.codeproject.com/KB/cs/TolgahanFormPropertySaver.aspx?fid=459883&df=90&mpp=25&noise=3&sort=Position&view=Quick
------解决方案--------------------
或者把属性值写进 INI文件里也可以
using System.Runtime.InteropServices;
[DllImport("kernel32")]//写入INI文件
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
[DllImport("kernel32")]//读取INI文件
private static extern long GetPrivateProfileString(string section, string key, string def, StringBuilder retVal,int size, string filePath);
------解决方案--------------------
建一个Map分别对应该Button的属性和设置值
既然有了反射的使用 那一切变得方便了
如果单机程序就把map设置为静态的
这样随时可以调用 如果不是单机就把它放到页面的主界面去,设置一个值就增加一个map元素,
然后每次打开界面用map来遍历需要恢复状态button,将属性一一还原
在这里我建议一下 其实大多数的button可用属性并不多且多为true,false类型
楼主不如建立几种状态的button同时覆盖,然后根据状态判断是哪个让他visable为true显示出来就好