如何使用C#中的Windows应用程序在组合框中添加一些文本 [英] how to add some text in combobox using windows application in c#

查看:46
本文介绍了如何使用C#中的Windows应用程序在组合框中添加一些文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已经将一些数据从数据库绑定到组合框了.我想在组合框中显示第一项为选择". [所以我想在组合框中同时添加文本和值]

在Web应用程序中,我们通常添加如下内容



already i have binded some data to combobox from the database. i want to display first item in combobox as Select. [so i want to add both text and value in combobox]

in web application we used to add as follows

ddlEmpId.Items.Insert(0, "--Select--");


像这样,我想在窗口应用程序"中为组合框添加内容.

认为您已明白我的意思.


Like this i want to add for combobox in window Application.

Think so u got my point.

推荐答案

this.comboBox1.Items.Insert(0, "Data");


这里没什么新鲜的.阅读完整的文章以探索更多内容
将项目添加到绑定的组合框 [ http://msdn.microsoft.com/en-us/library/aa983551%28v = vs.71%29.aspx [ ^ ]


Nothing new here. Have a read complete article to explore more
Add Item to Binded Combo Box[^]
http://msdn.microsoft.com/en-us/library/aa983551%28v=vs.71%29.aspx[^]


看看

this.comboBox1.DisplayMember = "PersonName";
this.comboBox1.ValueMember = "PersonID";


这篇关于如何使用C#中的Windows应用程序在组合框中添加一些文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆