Combobox - 如何将项目索引与记录ID匹配 [英] Combobox - How to match item index with record ID

查看:56
本文介绍了Combobox - 如何将项目索引与记录ID匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

表A有2列:

recID int

recName字符串


我需要将所有recName加载到组合框B中使用B.Items.Add(recName)。这个

没问题。

但是,我希望能够将ComboxBox B'的索引与表A'
$ b $相匹配b recID,以便我可以使用B.SelectedIndex更新任何使用表的表格

A'的recID。目前,我必须使用笨拙的例程来查找recID来自

B.text

非常感谢任何帮助。

谢谢


Bill

Table A has 2 columns:
recID int
recName String

I need to load all recName into combobox B using B.Items.Add(recName). This
is no problem.
However, I would like to be able to match ComboxBox B''s index with table A''s
recID so that I can use B.SelectedIndex to update any table that uses Table
A''s recID. Currently, I have to use a clumsy routine to find recID from
B.text
Any help is greatly appreciated.
Thanks

Bill

推荐答案

从使用Items.Add更改为使用DataSource的方法和

DisplayMember - 这将允许您将更复杂的数据对象

绑定到ComboBox,同时保留其他(不可见)信息 -

DataView将允许你可以过滤原始数据,并且可绑定到一个

组合框(任何实现IList的类都是可绑定的)

Change from using Items.Add to a method that uses DataSource and
DisplayMember -- this will allow you to bind a more complex data object
to the ComboBox while maintaining other (non-visible) information -- a
DataView will allow you to filter the orginal data and is bindable to a
combobox (any class that implements IList is bindable)


我可以有一些示例代码可以查看吗?

谢谢

比尔


" stand__sure" < ST ********* @ hotmail.com>在消息中写道

news:11 ********************* @ g47g2000cwa.googlegro ups.com ...
May I have some sample codes to review?
Thanks
Bill

"stand__sure" <st*********@hotmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
使用Items.Add更改为使用DataSource和
DisplayMember的方法 - 这将允许您将更复杂的数据对象绑定到ComboBox,同时保留其他(不可见)信息 -
DataView将允许您过滤原始数据并可绑定到
组合框(任何实现IList的类都可绑定)
Change from using Items.Add to a method that uses DataSource and
DisplayMember -- this will allow you to bind a more complex data object
to the ComboBox while maintaining other (non-visible) information -- a
DataView will allow you to filter the orginal data and is bindable to a
combobox (any class that implements IList is bindable)


http:// msdn2 .microsoft.com / library / c ... us,vs.80).aspx

http://msdn2.microsoft.com/library/c...us,vs.80).aspx


这篇关于Combobox - 如何将项目索引与记录ID匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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