I have the following structure
|-Table 1
|--PK IDT1
|--Name field
|-Table 2
|--PK ID
|--FK IDT1
|--Name field
I want to bind Table 1 to combobox1 and Table 2 to combobox2 so as when someone selects a value in combobox1, combobox2 populates with only the rows with the FK IDT1 value from combobox1. Is this possible with databinding or do I have to code it?
on the
FORM_LOADof your application just populate onlyComboBox1. this psuedocode may help you:ON FORM_LOAD of your Application:
On the SelectionChangeCommitted of your
ComboBox1The SelectedIndexChanged event is raised every time the SelectedIndex property value changes. If your ComboBox is initially empty then its SelectedIndex is -1. When you bind data to it the first item is selected by default and the SelectedIndex changes to 0. You are then explicitly setting the SelectedIndex to -1 again.
If you’re only interested in knowing when the user makes a selection then handle the SelectionChangeCommitted event instead.