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