Dave Burke : Freelance .NET Web Developer specializing in Online Communities

VS2005 Winforms IDE Design Mode Constructor Pacification

The VS2005 Winforms IDE is slick, sophisticated, groovy, but as Bogart said to Peter Lorre in Casablanca, "At a price, Ugarte, at a price."

The VS2005 IDE for Winforms is a rather sensitive creature in Design Mode.  Down-right demanding.  It gets easily confused in constant compile mode and runs home to Momma with nasty accusations like the one below.  All you wanted to do was pass a reference to another form or control and still work with the form in Design Mode.

You want to do this in the Designer class.

private void InitializeComponent()
{
    this.proposalList = new WinStreams.Controls.Proposals.ProposalList(this);
    ...
}   


Rather than changing that [ultra-sensitive] InitializeComponent() code and removing "this" just to design the form, or testing for DesignMode (which doesn't work anyway), give the stupid thing what it wants.  In the Main class, add a generic constructor passing a UserControl to go along with your class type.

ProposalPanel proposalPanel;
public ProposalList(ProposalPanel _proposalPanel)
{
    proposalPanel = _proposalPanel;
    InitializeComponent();
}
       
public ProposalList(UserControl _userControl)
{
    InitializeComponent();
}




It took me the longest time to figure out this hack...

Technorati Tags: , ,

Comments (0) | Post RSS RSS comment feed

Posted on 1/3/2006 9:53:00 PM by Dave Burke
Categories: .NET
Tags:

Related posts


Powered by BlogEngine.NET 2.0.0.36
Theme by Dave Burke