On 13 Sep, 20:05, Chris <coz1...@gmail.comwrote:
Hi,
I have a button on a form, that opens a second form where I'm cloning
a usercontrol, something akin to Access' continuous forms. Now, in
this usercontrol I have a couple comboboxes. Now I need to run a
query to get the data I want to set as these comboboxes' datasource.
How can I set the datasource just ONCE, as opposed to each time the
control is cloned? This is creating a huge performance hit. Thanks.
Perhaps pass the existing DataSource to your new form? Note that the
designer doesn't help you do this - but there is absolutely nothing to
stop you from creating something like below... then just update
DataSource [and possibly DataMember] when creating the sub-form.
public SubForm : Form {
// bs created / disposed as normal; combos bound to this
private BindingSource bs;
public object DataSource {
get { return bs.DataSource; }
set { bs.DataSource = value; }
}
public string DataMember {
get { return bs.DataMember; }
set { bs.DataMember = value;}
}
}