Windows应用程序 [英] windows applications

查看:66
本文介绍了Windows应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

我已将datsource分配给combobox,我想在combobox的起始项目中显示默认项目,例如选择项目".现在combobox,它直接显示数据.无论我分配了数据源如何,但我都希望将起始项目指定为--SELECT--在组合框中

如果有人可以帮助您实现这一目标,将不胜感激.

谢谢.

hi friends ,

I have Asssigned datsource to combobox and I want to display default item like "Select an Item" in combobox starting item.now combobox ,it displays data directly.whatever i assigned datasource,but i want to give starting item as --SELECT-- in combobox

If anyone can help on how to achieve this, it would be appreciated.

thanks.

推荐答案

在其中将数据源与comboBox绑定的地方,您只需在comboBox的DataSource中插入一个新项.作为ComboBox的"dt" ...
所以

where you are binding the datasource with the comboBox there you just insert a new Item in DataSource of comboBox .. i am assuming that you have binded a DataTable as "dt" to the ComboBox...
so

DataRow dr = dt.NewRow();/* ''dt'' is the DataSource of ComboxBox as DataTable*/
dr["columnName"]="---Select---";
dt.Rows.InsertAt(dr,0);
comboBox1.SelectedIndex=0;



必须在将DataSource绑定到ComboBox之后..
我以前的回答是完全错误的....
将ComboBox绑定到某些DataSource时,您将无法修改ComboBox的项目集合.
如果需要修改该组合框的项目,则必须修改该组合框的数据源...



this have to be after the binding of DataSource to ComboBox..
my previous answer was totally wrong....
you cant modify the Item Collection of a ComboBox when that ComboBox is binded to some DataSource...
if you need to modify the Items of that ComboBox then you must modify the DataSource of that ComboBox...


到目前为止,您尝试了什么?在此处发布一些代码,也许有人可以为您提供帮助.
What have you tried so far? Post some code here and maybe someone can help you.


mbScoohlName.Items.Insert(0,"--Select School--"); cmbScoohlName.SelectedIndex = 0; cmbScoohlName.DisplayMember ="SNAME"; cmbScoohlName.ValueMember ="ID"; cmbScoohlName.DataSource =数据集.Tables [0];
mbScoohlName.Items.Insert(0, "--Select School--"); cmbScoohlName.SelectedIndex = 0; cmbScoohlName.DisplayMember = "SNAME"; cmbScoohlName.ValueMember = "ID"; cmbScoohlName.DataSource = dataset.Tables[0];


这篇关于Windows应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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