我正在尝试将 a 添加CheckedComboBoxEdit
到GridView
usingWinForms
和devexpress
。这是我现在得到的:
using (var _db = new DB())
{
var isemirleri = _db.IsEmris.AsQueryable();
var oalist = _db.OperasyonAksakliks.AsQueryable();
gcIsEmirleri.DataSource =
(from i in isemirleri
select new {
ID = i.isEmriId,
İşEmriNo = i.isEmriNo,
Aksaklık = string.Join(",",
oalist
.Where(o => o.operasyonId == i.Operasyons.FirstOrDefault().operasyonId)
.Select(o => o.Durus.durusAdi).ToList())
}).ToList();
gvIsEmirleri.BeginUpdate();
//------------------------ THIS LINE -------------------------------------\\
//DataColumn col = new DataColumn("Aksaklık", typeof(string));
//------------------------ THIS LINE -------------------------------------\\
GridColumn column = gvIsEmirleri.Columns["Aksaklık"];
column.Caption = "Aksaklık";
column.Name = "Aksaklık";
gvIsEmirleri.EndUpdate();
RepositoryItemCheckedComboBoxEdit chk= new RepositoryItemCheckedComboBoxEdit();
chk.Items.Clear();
foreach (Durus d in _db.Durus.Where(q => q.aksaklikMi == true))
chk.Items.Add(new ListItem(d.durusId, d.durusAdi));
chk.EditValueChanged += new EventHandler(chk_EditValueChanged);
gvIsEmirleri.Columns["Aksaklık"].ColumnEdit = chk;
}
它成功地在网格上显示了Operasyons
逗号和CheckedComboBoxEdit
s 之间的现在(它显示了单元格右侧的小按钮)。
但是,当我单击单元格时,不会显示元素列表。我调试了项目并观察到它chk
设置正确并保持Items
原样。
如果我取消注释我标记为的行THIS LINE
并且没有添加Aksaklık
到gcIsEmirleri.DataSource
它成功添加列表并且可以正确使用,我可以将选中的元素添加到相关的数据库表中,但我看不到视图中的更改。我的意思是我看不到选定的元素,作为字符串组合或在行中检查。
我做错了什么或者我还能做些什么来让它发挥作用?