惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tenable Blog
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
H
Help Net Security
F
Fortinet All Blogs
MyScale Blog
MyScale Blog
宝玉的分享
宝玉的分享
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 司徒正美
量子位
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
Recorded Future
Recorded Future
博客园 - 三生石上(FineUI控件)
Vercel News
Vercel News
aimingoo的专栏
aimingoo的专栏
I
InfoQ
Microsoft Security Blog
Microsoft Security Blog
Scott Helme
Scott Helme
The Last Watchdog
The Last Watchdog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
AI
AI
WordPress大学
WordPress大学
Security Archives - TechRepublic
Security Archives - TechRepublic
Google Online Security Blog
Google Online Security Blog
U
Unit 42
V2EX - 技术
V2EX - 技术
MongoDB | Blog
MongoDB | Blog
Schneier on Security
Schneier on Security
博客园 - Franky
H
Heimdal Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Jina AI
Jina AI
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
Cloudbric
Cloudbric
B
Blog RSS Feed
N
News | PayPal Newsroom
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园_首页
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
雷峰网
雷峰网

博客园 - lining

输出的客户端 - lining - 博客园 List<T> - lining - 博客园 DateTime 赋空值 配色达人速成 批处理文件,删除文件及文件夹 - lining - 博客园 Source Code中pfx的密码 查找所有有某一列的表 如何修改 app.config 的配置信息 用例的获得 如何oracle调试存储过程 C# 中String 和 string 有什么区别 ora-00997:非法使用LONG数据类型 oracle如何判断一个字符串是否为数字或日期 C# 中的计时器 populate a listbox on winform with values from database 查看oracle执行计划 “Windows Workflow Foundation开发实战系列课程”中的数据库恢复 ASP.NET多语言版的开发 oracle数据导入导出imp/exp命令
winform技巧,listbox绑定,value,text, - lining - 博客园
lining · 2010-06-18 · via 博客园 - lining

from->http://www.cnblogs.com/virusswb/articles/1206888.html

private void button1_Click(object sender, EventArgs e)
{
    List<Vector> list = new List<Vector>();
    list.Add(new Vector("swb1", 1));
    list.Add(new Vector("swb2", 2));
    list.Add(new Vector("swb3", 3));
    list.Add(new Vector("swb4", 4));
    list.Add(new Vector("swb5", 5));
    listBox1.DataSource = list;
    listBox1.DisplayMember = "Name";
    listBox1.ValueMember = "Id";
    this.textBox1.Text = "Id";
    this.textBox2.Text = "Name";
}

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    //this.textBox1.Text = listBox1.SelectedItem
    object obj = listBox1.Items[this.listBox1.SelectedIndex];
    this.textBox1.Text = ((Vector)obj).Name;
    this.textBox2.Text = listBox1.SelectedValue.ToString(); ;
}

class Vector
{
    private string _name;
    private int _id;

    public string Name
    {
        get { return this._name; }
        set { this._name = value; }
    }
    public int Id
    {

        get { return this._id; }
        set { this._id = value; }
    }
    public Vector()
    { }
    public Vector(string name, int id)
    {
        this._name = name;
        this._id = id;
    }
}