Data binding - Visual Studio 2010
I am working with Visual Studio 2010.
Scenario:
I have 2 comboboxes. Contents of first combobox:
PC
DB...
Contents of Second combobox:
Password reset
Hardware problem
SQL
My question:
When I select 'PC' in the first combo box I want 'Password Reset' and 'Hardware Problem' to show up.
When I select 'DB' in first combobox I wan开发者_运维技巧t 'SQL' to show up in the second combo box.
Does anyone know how I can bind data from one combo box to the other ?
Also when I click on 'DB' ->'SQL' then a 3rd list box with data under these two combo items should be populated.
I feel this relates to data binding but not sure how to go about it.
ANy idea or link I could refer to??
Please help.
Thank you.
this question is very broad. Basically you have nothing besides the problem. So it's hard for anyone to give you good advise because it would amount to quite a few lines of code. So I try to give you a high-level overview.
The easiest way (without any desing-patterns or some advanced stuff) is just to put all you choices hardwired in combobox1. Then listen for the selecteditem-change event and fill combobox2 acording to what was selected. Rinse/Repeat with your optional combobox3.
To move on you can pull the values out of database-tables or config files instead of hardwiring them.
And finally you could move on to MVVM or a similiar pattern to to the theselction in a viewmodel and the representation in a view.
For now think about the first one and try to implement it - should be quite easy.
精彩评论