470,624 Members | 2,511 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,624 developers. It's quick & easy.

forms designer loads slow with derived control

PGP
I recently derived from a ComboBox to make a countries combo and included it
in couple of forms. The derived combo box loads an xml list of countries and
uses the DataSource and DisplayMember properties to point to the appropriate
node in xml. All this is done in the derived combo's constructor. This
causes forms designer to load slower as it seems to initialize these derived
combos with the country list.
If i did not care about the countries list at design time (I do want to see
the combo box as is though) and did care about the time taken to open forms
in designer, is there anything i could do to make this faster? Should i
wait to load the countries list? if so, when will i do it? Ideally, if i
could turn off the constructor code execution during form design that will
be great.

Priyesh
Apr 12 '07 #1
2 1744
On Apr 12, 3:49 pm, "PGP" <priyesh_do_not_replywrote:
I recently derived from a ComboBox to make a countries combo and included it
in couple of forms. The derived combo box loads an xml list of countries and
uses the DataSource and DisplayMember properties to point to the appropriate
node in xml. All this is done in the derived combo's constructor. This
causes forms designer to load slower as it seems to initialize these derived
combos with the country list.
If i did not care about the countries list at design time (I do want to see
the combo box as is though) and did care about the time taken to open forms
in designer, is there anything i could do to make this faster? Should i
wait to load the countries list? if so, when will i do it? Ideally, if i
could turn off the constructor code execution during form design that will
be great.
You should not do any heavy lifting in the constructor. You should
load database data later... I'm thinking maybe try overriding the
OnCreateControl() method and do it in there, like this:

protected override void OnCreateControl()
{
base.OnCreateControl();
if (!this.DesignMode)
{
... read stuff from database ...
}
}

The DesignMode property _should_ be set properly by then, so the
control should not attempt to load anything when in the designer. In
theory. :-)

Apr 12 '07 #2
PGP
You should not do any heavy lifting in the constructor. You should
load database data later... I'm thinking maybe try overriding the
OnCreateControl() method and do it in there, like this:

protected override void OnCreateControl()
{
base.OnCreateControl();
if (!this.DesignMode)
{
... read stuff from database ...
}
}

The DesignMode property _should_ be set properly by then, so the
control should not attempt to load anything when in the designer. In
theory. :-)
Bruce,
Thanks! DesignMode - That's exactly what i was looking for. It works!
Apr 13 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Joe Vrba | last post: by
2 posts views Thread by Zach | last post: by
8 posts views Thread by Jayme.Pechan | last post: by
5 posts views Thread by Doc John | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.