文本框作为查找字段 [英] Textbox as a lookup field

查看:101
本文介绍了文本框作为查找字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不得不问这个问题感到很尴尬.看来我一定错过了数据绑定的最基本方面(或者至少是在Google上查找内容的最基本方面),但是如果不编写各种事件处理程序然后进行手动绑定,我就无法弄清楚这一点.控制数据.

我想要的基本上是一个comboBox.也就是说,我希望有一个ValueMember和DisplayMember,它们通过基于ID但显示文本的相关表中的选择来连接主表.使用comboBox的问题在于它太简单和太小.

我所拥有的是一个联系人数据表,其中包含成千上万个条目.我希望用户单击textBox旁边的按钮(就像使用comboBox一样),并获取这些客户端的列表.但是,由于它的大小,列表需要是可排序的,可过滤的,可搜索的等.因此,我有一个带有dataGridView和所有控件的表单,以执行上述查找"联系人的操作.

剩下的就是,当用户选择一个联系人时,我需要将contactDisplayName存储在屏幕上,并将contactID存储在主表中.我真的很想通过数据绑定来做到这一点,而不是自己编写.

我简直不敢相信我在问这个问题!

I''m embarrassed to have to ask this question. It seems that I must be missing the most basic aspect of databinding (or at least the most basic aspect of looking something up with google), but I just can''t figure this out without writing all sorts of event handlers and then manual binding controls to the data.

What I want is essentially a comboBox. That is, I want to have a ValueMember and a DisplayMember that hook up a master table with a selection from a related table based on an ID but displaying text. The problem with using a comboBox is that it is too simple and too small.

What I have is a contacts data table with many thousands of entries. I want the user to click on a button next to a textBox (much like you would with a comboBox) and get a list of these clients. However, because of its size, the list needs to be sortable, filterable, searchable, etc. So I have a form with a dataGridView and all the controls to do the above "find" of a contact.

It remains that when the user selects a contact, I need to store the contactDisplayName on the screen and the contactID in the master table. I''d really like to do this with databinding as opposed to writing my own.

I just can''t believe I''m asking this question!

推荐答案

我不知道
I dont know if Extending the DataGridView[^] might give you some ideas.


谢谢,但是没有帮助.

为了更简单地说明问题,我需要一个支持复杂绑定的文本框",这样我就可以将其绑定到主表中的ID字段,但是要在控件中显示一个相关子项的文本字段.就像comboBox一样,但是有我自己的自定义下拉列表.就这样.

确实与datagridview无关.
Thanks, but no that didn''t help.

To restate the problem in simpler terms, what I need is a "textBox" that supports complex binding so that I can bind it to an ID field in a master table but have a text field displayed in the control from a related child. Exactly like a comboBox but with my own custom drop-down list. That''s all.

It has nothing to do with datagridview, really.


Brice,

我不是专家,但我认为实现此目标的方法是使用值转换器.

干杯,
查理
Brice,

I''m no expert but I think the way to do this is with value converters.

Cheers,
Charlie


这篇关于文本框作为查找字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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