Home > Ask the Microsoft .Net Development Experts > C# Development Questions & Answers > Take care with InitializeComponent
Ask The Win Development Expert: Questions & Answers
EMAIL THIS

Take care with InitializeComponent

Daniel Cazzulino EXPERT RESPONSE FROM: Daniel Cazzulino

Pose a Question
Other Win Development Categories
Meet all Win Development Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 08 August 2005

I have made a class that inherits Treeview class in one component of Vb.Net. I want this class to be used by another component.

When I draw TreeView in other component forms and in Window Generated Code, I instantiate that TreeView from an earlier component in the TreeView class.

It worked fine once, but not consistently.

I am not making a user control, just adding some functionalities to class, which can be used by any other component. -K.


>
EXPERT RESPONSE

You should NOT be modifying InitializeComponent method in the code-behind (or any of the variable definitions) by hand. That code is re-generated by the WinForms designer every time you make a change.

If your new control inherits from TreeView, you should be able to add it to the toolbox like any other control, and then drag it from there. If you want additional code to be emitted to the InitializeComponent, you will need to create a custom serializer for your control and use CodeDom.

You can read my article at CodeProject to learn more about it: http://www.codeproject.com/csharp/components.asp


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
ASP.NET and Web Development
Top ASP.NET expert advice from Danny Cazzulino
Access VB .NET Windows control on client side
Drop down list server control creates error message
Calling via command prompt from ASP.NET
Screen capturing
How to retrieve the MAC address of a client using ASP.NET
How to sort a dropdown list in ASP.NET
Accessing session variables in different pages
Automatically closing a .exe
Accessing a control on an independent application

C# Development
Top C# expert advice
Using LoadRunner for testing in .NET
GroupBox inheritance
Escape from mailto:
Windows Forms: Overriding the OnClosing method
Passing data between forms
Can I run a .NET app without installing .NET runtime?
Opening a link with parameters to a new window
Is it possible to open a child form in modal type?
Painting in the non-client area

C# programming language
Mono 2.0 moves .NET apps to Linux - includes migration analyzer
LINQ beyond queries: Strong-typed refection
Assembly versioning in the .NET Framework 2.0
Book excerpt: Creating graphical output using the .NET Compact Framework
Visual Studio 2008 Learning Guide: C# 3.0
Simonyi firm to address divide between domain experts and developers
On Extension Methods in C# and .NET Framework 3.5
Generate RSA public and private keys, export to XML
Book excerpt: Upgrading to Visual Studio 2005
Learning .NET: Tips for getting started with .NET development

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
C#  (SearchWinDevelopment.com)
GLib  (SearchWinDevelopment.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice

About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2000 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts