PropertyInfo[] objTempArr; BindingFlags objFlag = (BindingFlags.Public | BindingFlags.Instance); try { objTempArr = this.GetType().GetProperties(objFlag); for (int i = 0; i < objTempArr.Length; i++) { if (base.operations.Exists(s => s.Url == objTempArr[i].Name)) { objTempArr[i].SetValue(this, true, null); } else { objTempArr[i].SetValue(this, false, null); } } } catch (Exception err) { throw err; }
公开要控制的控件属性
public Boolean Button1Enabled { set { this.button1.Enabled = value; } } public Boolean Button2Enabled { set { this.button2.Enabled = value; } } public Boolean Button3Enabled { set { this.button3.Enabled = value; } } public Boolean Button4Enabled { set { this.button4.Enabled = value; } } public Boolean CheckBox1Enabled { set { this.checkBox1.Enabled = value; } } public Boolean TextBox1Endbled { set { this.textBox1.Enabled = value; } }