473,789 Members | 2,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1905
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.OnCreateCo ntrol();
if (!this.DesignMo de)
{
... 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.OnCreateCo ntrol();
if (!this.DesignMo de)
{
... 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
1154
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
9380
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 that I'd like to manipulate some of the derived controls using the VS.NET designer. However, when the base class is made abstract, I get the error "The designer must create an instance of type <...> but it cannot because the type is declared as...
0
1005
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 System::Windows::Forms::Panel class and add some custom functionality. I can easily create a new custom control project, change it to derive from Panel, and add the code to a Windows Forms app by hand to add an instance of my derived class, and it...
11
5309
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
3220
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 side of the form. It would be really nice if I could design all possible right hand side panels in the forms designer, then have some way to tell the framework "load the form represented by the class SuchAndSuchForm". What I have to resort to...
8
1475
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 derives or inherits from Form1 and we see the button in the top left corner. I can not change the position of the button in Form2 without changing it in Form1. I suppose this is probably how it is supposed to work but I'd like to be able to...
5
1830
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 will use some specific controls with some specific properties? For example, if I add to the Base Form a button with a black background ans Arial Font, will all the Forms be required to use this same Button? Thanks.
5
6124
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 suggestions. The one suggestion I've found that makes the most sense isn't working for me and after this most recent failure I'm really at a loss! ;0) I'm overriding WndProc and checking the Message.Msg property for the WM_KEYUP message. If anyone has...
12
11112
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. Here is a newbie mistake that I found myself doing (as a newbie), and that even a master programmer, the guru of this forum, Jon Skeet, missed! (He knows this I'm sure, but just didn't think this was my problem; LOL, I am needling him) If...
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5417
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3700
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.