Inherited controls being removed from InitializeComponent

  • Thread starter Thread starter Rob Blij
  • Start date Start date
Not sure what your problem is exactly... If you are editing the
InitializeComponent by hand then all your changes will be removed when you
use the form designer again. To add controls to your form in code rather
than in the designer, place the relevant code in the form constructor or
load event.

If you are inquiring about something else please be more descriptive and
include sample code/project that reproduces the problem.

Cheers
Daniel
 
Visual Studio will only correctly manage code in InitializeComponent if your
control has designer support. Search through the google archives of this
group for articles on how to do that.

Peter
 
Lets say I drop a textbox onto the form go into code behind and change it
to my inherited textbox ie NumericTextBox. I do edit initializecomponent
and it does work but sometimes while in design mode it just removes all
references to the control and I have to go and add it again once I have
closed the designer.

Im basically looking for a way that I can just tell my control to "Act like
a textbox". Must be some sort of attribute I can use but I will look. I
have looked a Peter's blog about design time support for controls but I'm
thinking there must be an easier way to tell it to just act like a textbox.

Thanks
Rob
 
After reading my previous reply I am sure you see why the
InitializeComponent loses your changes; every time you do something in the
form designer that method gets regenerated.

Follow Peter's suggestions for providing design support for you custom
control or my suggestion of placing the code in the ctor or OnLoad.

Cheers
Daniel
 
Writing design time control for a control which inherits from a standard
control is quite easy - you won't have too much work to do, see my blog for
details and take a look at the OpenNETCF code for TextBoxEx, PictureBoxEx
and ComboBoxEx as these all derive from the standard controls but with some
added properties and methods.
(the vault is at http://vault.netcf.tv Username: guest Password: guest)

Peter
 
great, thanks to you and daniel for you help


Peter Foot said:
Writing design time control for a control which inherits from a standard
control is quite easy - you won't have too much work to do, see my blog
for details and take a look at the OpenNETCF code for TextBoxEx,
PictureBoxEx and ComboBoxEx as these all derive from the standard controls
but with some added properties and methods.
(the vault is at http://vault.netcf.tv Username: guest Password: guest)

Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://www.peterfoot.net |
http://www.opennetcf.org
 
Back
Top