Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / September 2007

Tip: Looking for answers? Try searching our database.

User Control Datasource

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris - 13 Sep 2007 20:05 GMT
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.
Marc Gravell - 14 Sep 2007 05:34 GMT
> Hi,
>
[quoted text clipped - 4 lines]
> 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;}
       }
}

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.