Reference combobox used on another form?
-
I need to reference a combobox value (selectedvalue) on another form to the current form. How can I do this please? I tried setting the combobox modifier to 'Public' and while in NewForm using MainForm.myComboBox.selectedValue without success.
-
I need to reference a combobox value (selectedvalue) on another form to the current form. How can I do this please? I tried setting the combobox modifier to 'Public' and while in NewForm using MainForm.myComboBox.selectedValue without success.
Its bad practise to make such properties public as it lessens the object orientation of the control containing the combo box and starts going down the route of coupling the 2nd form to the 1st. The thing to do is to raise an event in the first form (the one containing the combo box) that the second form subscibes to. The event should probably (depending upon your requirements) be raised when the combo box seleceted value changes. Another way to solver you problem is to implement a model-view-viewmodel pattern, but this requires much more work if you have exisiting code.
CCC solved so far: 2 (including a Hard One!) 37!?!! - Randall, Clerks
-
Its bad practise to make such properties public as it lessens the object orientation of the control containing the combo box and starts going down the route of coupling the 2nd form to the 1st. The thing to do is to raise an event in the first form (the one containing the combo box) that the second form subscibes to. The event should probably (depending upon your requirements) be raised when the combo box seleceted value changes. Another way to solver you problem is to implement a model-view-viewmodel pattern, but this requires much more work if you have exisiting code.
CCC solved so far: 2 (including a Hard One!) 37!?!! - Randall, Clerks
Many thanks for that. I shall proceed accordingly. :thumbsup: