dev随笔记录
gridcontrol
bandedGridview
PrintHeader = false(不显示列头)
#region 勾选框全选或反选
List<string> islockList = new List<string>();//list
DataTable dt = new DataTable();
RepositoryItemCheckEdit rpsEdit = new RepositoryItemCheckEdit();
//把状态配置为多选框
gridView.Columns["锁定"].ColumnEdit = rpsEdit;
dt = (DataTable)gridControl.DataSource;
/// <summary>
/// 全选或清除
/// </summary>
/// <param name="_selectStatus"></param>
protected void SetGridSelectStatus(string _selectStatus)
{
_gridSelectStatus = true;
int columnscount = gridView.DataRowCount;
switch (_selectStatus)
{
case "all":
{
for (int i = 0; i < columnscount; i++)
{
if (GetIsLock(true, dt.Rows[i]["锁定"].ToString(), dt.Rows[i]["唯一值"].ToString()))
{
dt.Rows[i]["锁定"] = "True";
}
}
gridControl.DataSource = dt;
break;
}
case "clear":
{
for (int i = 0; i < columnscount; i++)
{
if (GetIsLock(false, dt.Rows[i]["锁定"].ToString(), dt.Rows[i]["唯一值"].ToString()))
{
dt.Rows[i]["锁定"] = "False";
}
}
gridControl.DataSource = dt;
islockList = new List<string>();//清除时将所有当前选中清空
break;
}
}
_gridSelectStatus = false;
}
private bool GetIsLock(bool selectStatus, string islock, string id)
{
if (selectStatus)
{
//在全部前已锁定
if (islock == "True")
{
//是不是现在勾选的
if (!islockList.Contains(id))
{
return false;
}
else
{
return true;
}
}
else
{
islockList.Add(id);
return true;
}
}
else
{
//是否现在勾选的
if (islockList.Contains(id))
{
return true;
}
else
{
return false;
}
}
}
#endregion