dev的CheckedListBoxControl的使用
赋值数据
chkcdess.DataSource = GlobalCache.Instace.AllCdes;//国家 chkcdess.DisplayMember = "carea"; chkcdess.ValueMember = "carea";
赋值选择数据
List<string> paras = model.cdess.Split(',').ToList(); var data = chkcdess.DataSource as List<op_syscdes>; for (int i = 0; i < data.Count(); i++) { if (paras.Where(item => item.Trim() == data[i].carea).Count() > 0) { chkcdess.SetItemChecked(i, true); } }
获取选择数据
List<string> cdes = new List<string>(); foreach (op_syscdes item in chkcdess.CheckedItems) { cdes.Add(item.carea); } model.cdess = string.Join(",", cdes);