vb.net2008中的组合框 [英] combobox in vb.net2008
问题描述
我有一个组合框作为下拉列表显示客户名和组合框用于汽车plateno和其他一些控件
cmbCustomernmae离开imb settign数据源为cmbPlateno作为所有plateno来自数据库的客户。
即时通讯使用vb.net 2008 mssql 2005 windows应用程序。代码如下:
私有 Sub cmbCustomerName_Leave( ByVal sender As 对象, ByVal e 作为 System.EventArgs)句柄 cmbCustomerName.Leave
' 填充数据的代码-removed这里是为了便于阅读
cmbPlateNo.ValueMember = car_id
cmbPlateNo.DisplayMember = plate_no
cmbPlateNo.DataSource = dt
cmbPlateNo .SelectedIndex = -1
end sub
问题是在幕后它用ctplateno填充每行dt并设置文本然后最终使selectedIndex为-1
因为我有很多与此相关的功能,所以它显示了cmbplateno上的每个值...正确或者是他们的另一种方式。
plz help
私人 Sub cmbCustomerName_Leave( ByVal sender As 对象, ByVal e As System.EventArgs)句柄 cmbCustomerName.Leave
' 填充数据的代码 - 在此处删除轻松阅读
cmbPlateNo.ValueMember = car_id
cmbPlateNo.DisplayMember = plate_no
cmbPlateNo.DataSource = dt.Tables( 0 )' 你忘了这个
cmbPlateNo.SelectedIndex = -1
end sub
cmbPlateNo.DataSource = dt
我没有忘记。我已经写过了,我使用的是datatable而不是数据集
I have a combobox as a dropdown showing customername and combobox for car plateno and some other controls
on cmbCustomernmae leave iam settign datasource for cmbPlateno as all plateno for that customer from database.
im using vb.net 2008 mssql 2005 windows app. code is as below:
Private Sub cmbCustomerName_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbCustomerName.Leave
'Code for fill datatable -removed here for easy reading
cmbPlateNo.ValueMember = "car_id"
cmbPlateNo.DisplayMember = "plate_no"
cmbPlateNo.DataSource = dt
cmbPlateNo.SelectedIndex = -1
end sub
the problem is behind the scenes it fills cmbplateno with each row of dt and setting text and then finally it makes selectedIndex as -1
As i have lot of functions related to this it shows each value on cmbplateno ..am id oing it right or is their anyother way of doing this.
plz help
try this
Private Sub cmbCustomerName_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbCustomerName.Leave 'Code for fill datatable -removed here for easy reading cmbPlateNo.ValueMember = "car_id" cmbPlateNo.DisplayMember = "plate_no" cmbPlateNo.DataSource = dt.Tables(0) 'you forgot this cmbPlateNo.SelectedIndex = -1 end sub
cmbPlateNo.DataSource = dt
I havent forgot that. I have already written it and Im using datatable not dataset
这篇关于vb.net2008中的组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!