//取出指定对象指定属性名的属性值
public
object
GetProperty()
{
Type type = BindingControl.GetType();
//获取类型(BindingControl,对象)
PropertyInfo proinfo=type.GetProperty(BindingProperty);
//BindingProperty,属性名
if
(proinfo!=
null
){
return
proinfo.GetValue(BindingControl,
null
);
//获取属性值
}
else
{
return
null
;
}
}
//指定对象指定属性名的属性赋值
public
void
SetProperty(
object
Value)
{
Type type = BindingControl.GetType();
//获取类型(BindingControl,对象)
PropertyInfo proinfo = type.GetProperty(BindingProperty);
//BindingProperty,属性名
if
(proinfo !=
null
)
{
proinfo.SetValue(BindingControl, Value,
null
);
}
else
{
throw
new
Exception(
"该控件没有这个属性!"
);
}
}