|
-
Dec 18th, 2007, 10:30 PM
#1
Thread Starter
Addicted Member
[2005] Constructor question
How can I put additional method if I want to add a constructor. Like example with Form Class, when I add constructor, it always add a method called InitializeComponent() and a comment
vb Code:
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub
Regards
Michael
-
Dec 18th, 2007, 10:39 PM
#2
Frenzied Member
Re: [2005] Constructor question
Feel free to insert any other method calls or code you want in there. InitializeComponent is always called regardless of whether you explicitly create the constructor or not. Basically it just initializes all the controls and components on the form and shows them. You can add other method calls after you call that one.
-
Dec 18th, 2007, 10:54 PM
#3
Thread Starter
Addicted Member
Re: [2005] Constructor question
What I mean is, when I insert a constructor in a form class, it always insert InitializeComponent() automatically. I want my class has this ability too, since my class is inherited by several class and all of them must initiate the same method if I insert a constructor...
-
Dec 18th, 2007, 10:58 PM
#4
Frenzied Member
Re: [2005] Constructor question
I'm not really sure what you mean. You wrote your own class? Is it inheriting from the System.Windows.Forms.Form class? You can call the InitializeComponent method wherever you want, even if the constructor is overloaded.
Maybe I'm just tired but I can't fully understand what you mean.
-
Dec 18th, 2007, 11:22 PM
#5
Fanatic Member
Re: [2005] Constructor question
You can create your own ItemTemplate in VS2005 that will construct a default class with any comments or methods already defined. Try search google for ItemTemplate example.
http://msdn.microsoft.com/msdnmag/is...CodeTemplates/
Last edited by Jumpercables; Dec 18th, 2007 at 11:25 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|