User Control Datasource

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

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.
 
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;}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top