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 / Windows Forms / WinForm General / December 2004

Tip: Looking for answers? Try searching our database.

Load event in user control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mamil@bezeqint.net - 25 Dec 2004 17:11 GMT
Hi Gurus.

I'm doing my first steps in the Winforms realm (I dealt mainly with
ASP.NET until now), and I've stumbled across issue I really cannot
solve and that seems extremely stupid to even ask about, so please
forgive me...

I need to execute some logic in the Load event of the control. Problem
is - I can't find that event for user controls! This logic cannot be
executed in the control's constructor, because its properties are not
set yet. I don't want to modify the InitializeComponent method code, as
I understand it is strongly un-recommened.

In ASP.NET, there is a Load event for every control, which enables me
to do just that. What is its equivalent in Winforms controls?

Thanks!
Jeff Gaines - 25 Dec 2004 17:31 GMT
> Hi Gurus.
>
[quoted text clipped - 13 lines]
>
> Thanks!

A control based on UserControl does have a load event, is your control
based on UserControl or another type of control?

Signature

Jeff Gaines
Posted with XanaNews 1.17.1.2 http://www.wilsonc.demon.co.uk/delphi.htm

mamil@bezeqint.net - 25 Dec 2004 17:45 GMT
My control inherits from the ComboBox control.
Is there any difference between regular UserControl and inherited
control?
Bill Woodruff - 26 Dec 2004 03:21 GMT
mamil@bezeqint.net wrote: >> Problem is - I can't find that event for user
controls !

You could create a UserControl, then, in its load event, create an instance of
your over-ridden combobox, set its dockstyle to 'fill.

In a similar situation (a compound control inheriting from Label) I used the
following code to make sure I called the code that built the run-time "ui" only
when in run-time mode : whether this can be adapted to function in exactly the
way you want ?

 // Override 'CreateControl to avoid design-time errors :
 // build the UI only when we are NOT in design mode
 protected override void OnCreateControl()
 {
      base.OnCreateControl();
      if(this.Site == null)
      {
           CreateUI();
     }
 }

best, Bill Woodruff
dotScience
Chiang Mai, Thailand

Rate this thread:







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.