0

我想要做的是添加一个由复选框填充并放置在网格左侧的列。网格行是从查询绑定的。我有这个代码:

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);,它得到了错误。我怎样才能做到这一点?谢谢。

4

2 回答 2

1

试试这个,

tblClaim.Columns.Add("Process", typeof(bool)).SetOrdinal(0);

这会将“进程”列的索引设置为 0

于 2013-04-09T02:56:50.990 回答
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;
于 2013-04-09T08:14:10.673 回答