Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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!
Posted

I dont know if Extending the DataGridView[^] might give you some ideas.
 
Share this answer
 
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.
 
Share this answer
 
Brice,

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

Cheers,
Charlie
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900