我想要做的是添加一个由复选框填充并放在网格左侧的列。网格行是从查询绑定的。我有这段代码:
string query = "SELECT TransID, Company, Period, EmpID, Employee FROM Trx"
DataTable tblClaim;
tblClaim = DB.sql.Select(query);
tblClaim.Columns.Add("Process", typeof(bool)); //I want this column placed on the left side of the grid
gcxClaim.ExGridControl.DataSource = tblClaim;
我从该代码得到的是,禁用该复选框并将列放在右侧。当我尝试在tblClaim.Columns.Add("Process", typeof(bool));
之前放置tblClaim = DB.sql.Select(query);
时,却出错了。我怎样才能做到这一点?感谢。
答案 0 :(得分:1)
试试这个,
tblClaim.Columns.Add("Process", typeof(bool)).SetOrdinal(0);
这会将“Process”列的索引设置为0
答案 1 :(得分:0)
它的工作原理如下:
string query = "SELECT CAST(1 AS BIT) AS Process, TransID, Company, Period, EmpID, Employee FROM Trx"
tblClaim = DB.sql.Select(query);
gcxClaim.ExGridControl.DataSource = tblClaim;
gcxClaim.ExGridView.OptionsBehavior.Editable = true;
for (int i = 0; i < tblClaim.Columns.Count; i++)
{
gcxClaim.ExGridView.Columns[i].OptionsColumn.AllowEdit = false;
}
gcxClaim.ExGridView.Columns["Process"].OptionsColumn.AllowEdit = true;