内容显示页
 
类别:.Net + C# | 浏览(127) | 2008-9-3 17:03:10

public class ListItem
{
    private string _key = string.Empty;
    private string _value = string.Empty;
    public ListItem(string pKey, string pValue)
    {
        _key = pKey;
        _value = pValue;
    }
    public override string ToString()
    {
        return this._value;
    }
    public string Key
    {
        get
        {
            return this._key;
        }
        set
        {
            this._key = value;
        }
    }
    public string Value
    {
        get
        {
            return this._value;
        }
        set
        {
            this._value = value;
        }
    }
}


///////////////////////////////////////////////////////////////
comboBox1.Items.Add(new ListItem("请选择", "0"));
DataView dv = Comm.DB.ExecuteDataSet("select txtName,ID from dept where ParentID=24").Tables[0].DefaultView;
foreach (DataRowView drv in dv)
{
    comboBox1.Items.Add(new ListItem(drv["txtName"].ToString() , drv["ID"].ToString()));
}
comboBox1.DisplayMember = "Key";
comboBox1.ValueMember = "Value";
comboBox1.SelectedIndex = 0;

///////////////////////////////////////////////////////////////////
 MessageBox.Show(((ListItem)comboBox1.SelectedItem).Value);


引用本页地址:http://www.yongfa365.com/item/comboBox-dropdownlist-droplist-Tian-Jia-value.html
 
上一篇:代码生成器
下一篇:年薪30万
 
相关链接
 
网友评论:
姓名: 记住我
网址:
邮箱:
内容:
验证码:  验证码图片 看不清? 换张图试试
 
     
 
 
文章分类
 
 
专题(3)
 
.Net + C#(41)
 
ASP+VBS(153)
 
 
 
Linux(10)
 
 
 
web 2.0(24)
 
 
 
 
 
心程(59)
 
生活(80)
 
 
     

Power by :柳永法(yongfa365)'Blog | Model by :hibaidu | CSS by:众网友 | 京ICP备07011491号  QQ:64049027  E-mail:64049027qq.com

本空间赞助商:北京中科兴联信息技术有限公司