467,906 Members | 1,597 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,906 developers. It's quick & easy.

How to use a user control's constructor which has parameters in design view mode in Visual Studio 2003? ,What is mechanism for generating InitializeComponent(){}?

I have a user control, it must set a property when it is just created, so I set it in its constructor, which has an parameter to specify the property .

For example:
public class ExecQuest : UserControl,IOleClientSite,IDocHostUIHandler
{
public ExecQuest(Type showType)
{
this.showType = showType;
}

}

Becuse showType property should not have default value and must be set at the begining, I don't want the user control class has default constructor with no arguements.

But When I put a user control on a form, seems auto-generated code in InitializeComponent() {} use control's default constructor.
I can only manually change code in InitializeComponent(), which ruined if I go to design mode and InitializeComponent() generated again.

public class frmExecute : System.Windows.Forms.Form
{
private void InitializeComponent()
{
this.EQ = new ExecQuest(Type.Builder); // manyally edited, it was this.EQ = new ExecQuest()
}
}

What is better way solve this problem?

In other words,
a.. What is mechanism for generating InitializeComponent(){}?
b.. How to use a user control's constructor which has parameters in design view mode in Visual Studio 2003?
Thanks a lot!
Ryan
Nov 16 '05 #1
  • viewed: 1425
Share:

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Z D | last post: by
5 posts views Thread by Marcel Gelijk | last post: by
10 posts views Thread by Adis | last post: by
reply views Thread by Adis | last post: by
1 post views Thread by Tony Johansson | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.