好久没有来博客园了,抽空总结下用过的下拉框吧

一.DEV控件CheckedComboBoxEdit(工具箱—>Common Control—>CheckedComboBoxEdit)

 1  //说明:若ShowButtons属性为true,则显示OK和Cancel按钮;
 2             //若ShowButtons属性为true,ShowPopupCloseButton为false,则显示OK,不显示Cancel按钮
 3             //若ShowButtons属性为false,ShowPopupCloseButton为true,则下拉框左下角会显示×表示取消;
 4             //若二者都为false,都按钮和×都不显示   以上情况可以在实际中进行试验(亲测,觉得这俩属性做的很细致)
 5             checkedComboBoxEdit1.Properties.ShowButtons = true;//是否显示“OK”,和Cancel按钮
 6             checkedComboBoxEdit1.Properties.ShowPopupCloseButton = false;//是否显示Cancel
 7 
 8             checkedComboBoxEdit1.Properties.SelectAllItemCaption = "全选";//默认为"Select All"
 9             checkedComboBoxEdit1.Properties.SelectAllItemVisible = true;//全选框是否可见
10             checkedComboBoxEdit1.Properties.SeparatorChar = ','; //多选时显示值的分割符(默认,)
常用属性
 1       //法①
 2             List<string> lstData = new List<string>();
 3             lstData.Add("aa");
 4             lstData.Add("bb");
 5             lstData.Add("cc");
 6             checkedComboBoxEdit1.Properties.DataSource = lstData;
 7 
 8      // 法②
 9          string[]  strViewName = new string[] { "A", "B", "C" };
10           for (int i = 0; i < strViewName.Length; i++)
11           {
12               string str = "显示值" + "-" + i.ToString();
13               //参数说明:绑定的实际值,显示值,选项默认是否选中,最后一个参数是选择项是否可用
14               checkedComboBoxEdit1.Properties.Items.Add(strViewName[i], str, CheckState.Unchecked, true);
15           }
绑定数据源
1   //获取到实际的绑定的值
2                 List<object> lst = checkedComboBoxEdit1.Properties.Items.GetCheckedValues();
3                 
4                 //获取到的显示值
5                 string strText = checkedComboBoxEdit1.Text;
6                 string[] strGetData = strText.Split(',');
获checkedComboBoxEdit1的值

 

posted on 2018-03-07 14:16  梦想&现实  阅读(1664)  评论(0编辑  收藏  举报