winform中的ListBox和ComboBox绑定数据用法实例
作者:shichen2014 时间:2023-09-24 05:02:13
本文实例讲述了winform中的ListBox和ComboBox绑定数据用法。分享给大家供大家参考。具体实现方法如下:
本例实现将集合数据绑定到ListBox和ComboBox控件,界面上显示某个属性的内容,代码如下:
//...
//自定义了Person类(有Name,Age,Heigth等属性)
List<Person> persons=new List<Person>();
persons.Add(new Person("WuMiao",18,175));
persons.Add(new Person("YeXinYv",20,170));
persons.Add(new Person("WuDong",18,175));
//ListBox控件实现
lb_PersonsList.DataSource=persons; //指定数据源
lb_PersonList.DisplayMember="Name"; //界面显示的是人的名字
//ComboBox控件实现 (与ListBox的实现类似)
cmb_PersonList.DataSource=persons;
cmb_PersonList.DisplayMember="Name";
希望本文所述对大家的C#程序设计有所帮助。
标签:winform,ListBox,ComboBox
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
java学生管理系统界面简单实现(全)
2023-11-28 21:35:25
c++中的string常用函数用法总结
2023-11-02 16:44:02
详解Android应用开发中Intent的作用及使用方法
2021-11-20 04:45:03
Java自动生成趋势比对数据的方法分享
2023-11-25 18:29:18
![](https://img.aspxhome.com/file/2023/7/61087_0s.jpg)
Mybatis与Jpa的区别和性能对比总结
2022-09-17 16:08:45
C# Dockpanel入门基础必看篇
2023-02-24 18:50:42
![](https://img.aspxhome.com/file/2023/9/102229_0s.jpg)
浅析Java的Hibernate框架中的继承关系设计
2021-10-18 03:10:03
![](https://img.aspxhome.com/file/2023/6/75796_0s.png)
Flutter Widget开发之Focus组件图文详解
2023-06-21 03:47:41
![](https://img.aspxhome.com/file/2023/7/101827_0s.jpg)
SpringBoot实现接口等幂次校验的示例代码
2022-01-21 10:49:00
Spring Bean的初始化和销毁实例详解
2023-10-28 05:56:04
springtask 的使用方法和 cron 表达式解析
2023-06-19 20:05:56
SpringBoot封装响应数据实现过程详解
2023-01-17 21:32:51
![](https://img.aspxhome.com/file/2023/5/88215_0s.png)
Android实现图片转高斯模糊以及高斯模糊布局
2023-10-20 16:10:23
C#键值对容器的介绍
2023-04-14 12:26:56
详解java8在Collection中新增加的方法removeIf
2022-06-04 20:51:45
JavaGUI常用三种布局使用介绍
2023-05-19 08:01:06
![](https://img.aspxhome.com/file/2023/6/73036_0s.png)
实例详解Android解决按钮重复点击问题
2023-10-16 09:10:12
Spring RabbitMQ死信机制原理实例详解
2022-04-29 18:52:18
C# WinForm编程获取文件物理路径的方法
2021-08-30 16:06:06
一款适用于Android平台的俄罗斯方块
2023-02-25 02:38:35
![](https://img.aspxhome.com/file/2023/2/122062_0s.jpg)