日期:2014-05-17 浏览次数:20730 次
public void Method(CheckBox checkbox, params Control[] controls)
{
if (checkbox.Checked)
{
foreach (var item in controls)
{
var propertyInfo = item.GetType().GetProperty("ReadOnly");
if (propertyInfo == null)
continue;
propertyInfo.SetValue(item, false, null);
}
}
else
{
foreach (var item in controls)
{
var propertyInfo = item.GetType().GetProperty("ReadOnly");
if (propertyInfo == null)
continue;
propertyInfo.SetValue(item, true, null);
}
}
}
public partial class Form1 : Form
{
public Form1()
{