zoukankan      html  css  js  c++  java
  • DevExpress ComboboxEdit绑定key value值

    DevExpress中ComboboxEdit是没有DataSource属性的,所以不能绑定数据源,只能一项一项的添加。

    我现在需要给ComboboxEdit绑定键值对的属性,具体操作如下:

    1、新建一个ListItem类,继承object。

    public class ListItem : Object
        {
            public string Text { get; set; }
    
            public string Value { get; set; }
    
            public ListItem(string text, string value)
            {
                this.Text = text;
                this.Value = value;
            }
    
            public override string ToString()
            {
                return this.Text;
            }
        }

    2、绑定数据源

    string text = string.Empty;
    string value = string.Empty;
    ListItem item = null;
    StartBranchId.Properties.Items.Clear();
    foreach (DataRow row in data.Tables["Branch"].Rows)
    {
        item = new ListItem(row["xName"].ToString(), row["Id"].ToString());
        this.StartBranchId.Properties.Items.Add(item);
    }

    3、取值

    MessageBox.Show((StartBranchId.SelectedItem as ListItem).Text);
    MessageBox.Show((StartBranchId.SelectedItem as ListItem).Value);
  • 相关阅读:
    Zookeeper入门
    Redis五种数据类型
    shardingJDBC分库分表
    RabbitMQ入门
    Spring-Boot
    spring-mvc
    oracle一些对表的操作命令
    对IFeatureClass的选择结果进行再次选择及排序
    关于基础 DBMS 错误 ORA-01654的总结
    Linq 如何实现 in 与 not in
  • 原文地址:https://www.cnblogs.com/mikemao/p/14450516.html
Copyright © 2011-2022 走看看