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;
    }
  • 相关阅读:
    Spring AOP概念理解
    五分钟快速掌握RPC原理及实现
    Linux常用命令汇总
    一致性哈希算法原理
    RPC原理及实现
    IO设计模式:Reactor和Proactor对比
    到底什么时候该使用MQ?
    eclipse查看一个方法被谁引用(调用)的快捷键四种方式
    maven build pulgin
    VSCode 常用setiings.json设置
  • 原文地址:https://www.cnblogs.com/w2011/p/3529271.html
Copyright © 2011-2022 走看看