473,321 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

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 1881
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tony | last post by:
Derived Forms resizing in dotnet. (Fix) Problem: If you have a form base class: public frmBase : System.Windows.Forms { public frmBase { // DefaultFormFont is new Font("Tahoma", 10);
2
by: Joe Vrba | last post by:
I'm building a family of components derived from UserControl. There's an abstract base class to ensure basic functionality and then numerous other controls derived from that. The problem is...
0
by: Patrick Aikens | last post by:
This question is for .NET 2005 beta 1 (we can't move to beta 2 yet at my workplace). This is probably a true newbie question or a beta bug, but I'm a bit lost on this... I want to extend the...
11
by: Crirus | last post by:
I need to derive the Windows.Forms.Control 2 times so I design a class like this Public Class BMControl Inherits System.Windows.Forms.UserControl Public Class MapControl Inherits BMControl
2
by: Zach | last post by:
I have a situation similar to what you see in Visual Studio Options menu. A Tree View on the left, and depending on what type of node you click it dynamically loads a panel into the right hand...
8
by: Jayme.Pechan | last post by:
Is it possible to allow derived forms to change the layout of the buttons and UI elements on a form? For example, I make Form1 with a button in the top left corner. I then make a Form2 that...
5
by: Doc John | last post by:
I need to create several Windows Forms and I'm thinking of creating a base Form from which I can derive all Forms. Is it possible to include something in that Base Form so that all Forms I create...
5
by: sklett | last post by:
I know that Panel (and most of it's derivitives) don't raise keyboard events. I *really* need to catch keyboard events though so I've been googling the topic and have found quite a few...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.