[DevExpress]控件-checkboxlist之运用

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://david.blog.csdn.net/article/details/51119688

数据绑定:

            string strSql = "SELECT [UserName],[Mail] FROM [OA].[dbo].[DZ_Users]";
            DataTable dt = new DataTable();
            dt = DbHelperSQL.Query(strSql.ToString()).Tables[0];


            chklboxL.DataSource = dt;
            chklboxL.DisplayMember = "UserName";
            chklboxL.ValueMember = "Mail";


            this.checkedComboBoxEdit1.Properties.DataSource = dt;
            this.checkedComboBoxEdit1.Properties.DisplayMember = "UserName";
            this.checkedComboBoxEdit1.Properties.ValueMember = "Mail";

            checkedComboBoxEdit1.EditValue = "test1@zettlercn.com,test2@zettlercn.com";     //默认值

获取:

       string mail = string.Empty;
            DataRowView value = chklboxL.SelectedValue as DataRowView;
            BaseCheckedListBoxControl.CheckedItemCollection checkboxs = chklboxL.CheckedItems;
            foreach (DataRowView item in checkboxs)
            {
                string name = item["UserName"].ToString();
                mail += item["Mail"].ToString() + ",";
            }
            XtraMessageBox.Show(mail.Substring(0, mail.Length - 1), "警告");

效果:



展开阅读全文

没有更多推荐了,返回首页