I have a combobox in a dialog box form. I need to fill this combo with the List<> from parent form. How to do that as I cannot pass the List<> via dialog box constructor.
frmChild frm = new frmChild();
frm.ShowDialog();
You can add a property or method on your form, that takes the List<items>
and populates the ComboBox.
For example:
List<ItemType> items = GetItemsForFormsComboBox();
frmChild frm = new frmChild();
frm.SetComboItems(items);
frm.ShowDialog();
// in the form
public void SetComboItems(List<ItemType> items)
{
foreach(var item in items)
{
myCombo.Add( /* construct combo item and use item to populate it here */ );
}
}
You may make a property of your dialog to get/set List<> data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With