zoukankan      html  css  js  c++  java
  • DevExpress ComboBoxEdit 添加值

    今天在使用ComboBoxEdit 这个控件的时候,不知道怎么添加值.

    在官网上找到代码。在这里做个记录

     ComboBoxEdit combo = new ComboBoxEdit();
      ComboBoxItemCollection coll = combo.Properties.Items;
      coll.BeginUpdate();
      try {
        coll.Add(new PersonInfo("Sven", "Petersen"));
        coll.Add(new PersonInfo("Cheryl", "Saylor"));
        coll.Add(new PersonInfo("Dirk", "Luchte"));
      }
      finally {
        coll.EndUpdate();
      }
      combo.SelectedIndex = -1;
      
      Controls.Add(combo);
    
    
    //... 
    
      public class PersonInfo {
        private string _firstName;
        private string _lastName;
        
        public PersonInfo(string firstName, string lastName) {
          _firstName = firstName;
          _lastName = lastName;
        }
    
        public override string ToString() {
          return _firstName + " " + _lastName;
        }
      }
     public class ExComboBox
        {
            public int Index { get; set; }
            public string Key { get; set; }
            public string Value { get; set; }
            public string Tag { get; set; }
    
            public ExComboBox(int pIndex, string pKey, string pValue)
            {
                this.Index = pIndex;
                this.Key = pKey;
                this.Value = pValue;
            }
    
            public ExComboBox(int pIndex, string pKey, string pValue, string pTag)
            {
                this.Index = pIndex;
                this.Key = pKey;
                this.Value = pValue;
                this.Tag = pTag;
            }
            public override string ToString()
            {
                return this.Value;
            }
        }
      comboBox.Properties.Items.Add("全部");
                     for (int i = 0; i < arg.Result.Count; i++)
                          {
                             comboBox.Properties.Items.Add(new ExComboBox(i, arg.Result[i].F_RoadwayCode, arg.Result[i].F_StationCode.ToString()));
                           }
      void comboBoxEditStation_SelectedValueChanged(object sender, System.EventArgs e)
            {
                var exComboBox1 = this.comboBoxEditRoadWay.SelectedItem as ExComboBox;
    }
  • 相关阅读:
    系统文件夹路径的系统宏定义
    大数问题:用字符串解决大数相加和相乘
    C++中四种类型转换方式(ynamic_cast,const_cast,static_cast,reinterpret_cast)
    浅谈bitmap算法
    linux分享一:网络设置
    php分享十六:php读取大文件总结
    面试题一:linux面试题
    php分享十五:php的命令行操作
    查询系统负载信息 Linux 命令详解
    Linux守护进程
  • 原文地址:https://www.cnblogs.com/w2011/p/3529271.html
Copyright © 2011-2022 走看看