1.gridcontrol添加控件元素
设置属性:Autohight =false
Buttom kind =Combo
2.绑定数据
this.repositoryItemCheckedComboBoxEdit1.DataSource = BLL.role_user_manage.Qry_user(userCondition);
this.repositoryItemCheckedComboBoxEdit1.ValueMember = "user_id";
this.repositoryItemCheckedComboBoxEdit1.DisplayMember = "email";
3.添加修改事件
/// <summary>
/// 添加用户1,修改数据库表字段信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void repositoryItemCheckedComboBoxEdit1_EditValueChanged(object sender, EventArgs e)
{
int id = (int)this.gridView_task.GetFocusedRowCellValue("id");
string user = "";
List<object> list_core = this.repositoryItemCheckedComboBoxEdit1.Items.GetCheckedValues();
string ids = string.Empty;
for (int i = 0; i < repositoryItemCheckedComboBoxEdit1.Items.Count; i++)
{
CheckedListBoxItem item = repositoryItemCheckedComboBoxEdit1.Items[i];
if (item.CheckState == CheckState.Checked)
{
if (ids == string.Empty)
{
ids = item.Description.ToString();
}
else
{
ids += string.Format(",{0}", item.Description.ToString());
}
}
}
if (false == cmb_List.Edit_task_mailto(id, ids))
{
MessageBox.Show("配置失败,请联系系统开发人员。");
}
this.gridView_task.SetFocusedRowCellValue("mailto",ids);
//MessageBox.Show(ids);
}
private void repositoryItemCheckedComboBoxEdit1_CustomDisplayText(object sender, CustomDisplayTextEventArgs e)
{
string items = repositoryItemCheckedComboBoxEdit1.GetCheckedItems().ToString();
List<string> checkItems = new List<string>();
if (items.Contains(","))
{
string[] itemValue = items.Split(',');
foreach (string i in itemValue)
{
checkItems.Add(i);
}
}
}
4.实现效果(选择用户列,实现多选)