// <summary>
// 设置控件的事件OnCheckChanged
// </summary>
private void OnCheckChanged(object sender, EventArgs e)
{
if (CheckedChanged != null){CheckedChanged(sender, e);}
}
// <summary>
//定义控件的属性Name
// </summary>
private string name;
public string Name
{
get{return(name);}
set{name = value;}
}
// <summary>
// 定义控件的属性DataField
// </summary>
private string dataField;
public string DataField
{
get{return dataField;}
set{dataField=value;}
}
// <summary>
// 定义控件的属性AutoPostback
// </summary>
private bool autoPostBack = false;
public bool AutoPostBack
{
set{autoPostBack = value;}
get{return autoPostBack;}
}
// <summary>
// 定义控件的数据绑定函数BindData()
// </summary>
private void BindData(object sender, EventArgs e)
{
//找到CheckBox控件
CheckBox box = (CheckBox) sender;
DataGridItem container = (DataGridItem) box.NamingContainer;
box.Checked = false;
box.Enabled = (readOnly == true) ? false:true;
//获取数据
string data =
((DataRowView) container.DataItem)[dataField].ToString();
//获取数据类型
Type t = ((DataRowView)container.DataItem).DataView.Table.Columns[
dataField].DataType;
if (data.Length>0)
{
switch (t.ToString())
{ //设置控件的值
case "System.Boolean":
文章来源于领测软件测试网 https://www.ltesting.net/