Databinding a comboList to a DataView

I have a dataview containing rows of data. The data, lets say, contains a number of categories (several in category1, a couple in category2 etc). On my form, I have different comboBoxes for each category for which I want to list.

How do I, through databinding, list the data in each category to their respective comboBoxes? I think I'm nearly there, just need help at ????

What I have so far:

MyDataView.RowFilter = "CategoryColumn = 'CategoryValue'"
ComboBox1.DataBindings.Add("????", MyDataView, "DataViewColumn")

  'repeat the above changing the Category and ComboBox's accordingly

If I replace ???? with:
   - "Text", I just get the first row
   - "Items" throws an exception as the Items property is read only
   - "DisplayMember" nothing

IvanHowarthAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SanclerCommented:
You do your bindings in a different way for controls that contain "lists" - like comboboxes.  Try this

   ComboBox1.DataSource = MyDataView
   ComboBox1.DisplayMember = "DataViewColumn"

and similar for your other categories/comboboxes.

Often, when you are using comboboxes, you will want them to display some meaningful text but actually return some coded data.  If that's the case here, you might also want

   ComboBox1.ValueMember = "DifferentDataViewColumn"

Roger
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IvanHowarthAuthor Commented:
Since posting the question, I have (found and) used your first suggestion which does give the desired result. I just thought there might then be a way of doing it in a single line. Obviously not.

Thanks anyway.
0
IvanHowarthAuthor Commented:
Problem with the above:

Because all the different categories are in the same column (input by user at runtime), all my comboboxes are listing all the same items. Is there a way of getting each of the comboboxes to filter (and thus retain) their own data from this one column?

0
SanclerCommented:
>>
Is there a way of getting each of the comboboxes to filter (and thus retain) their own data from this one column?
<<

I don't know of a way to get the combobox itself to filter.  But if you use a different dataview for each combobox, you could apply the filter to the dataview, I think.

Roger
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.