Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / April 2007

Tip: Looking for answers? Try searching our database.

VB.NET 2005 newby question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Oleg Subachev - 21 Apr 2007 09:58 GMT
In VB.NET 2003 there is main form's constructor which
contains InitializeComponent() call and a placeholder below
to put custom initialization code there.

But there is no such constructor in VB.NET 2005 code
(though destructor is in place).

Where can I put custom initialization code in VB.NET 2005 ?

And, apropos, where is InitializeComponent() called from ?

Oleg Subachev
Kerry Moorman - 21 Apr 2007 16:08 GMT
Oleg,

The call to InitializeComponent is still in the form's constructor.

To view the constructor, select the form object from the combobox at the top
left of the form's code window. From the combobox at the top right of the
code window, select New.

Kerry Moorman

> In VB.NET 2003 there is main form's constructor which
> contains InitializeComponent() call and a placeholder below
[quoted text clipped - 8 lines]
>
> Oleg Subachev
Oleg Subachev - 23 Apr 2007 07:41 GMT
> The call to InitializeComponent is still in the form's constructor.
>
> To view the constructor, select the form object from the combobox at the
> top
> left of the form's code window. From the combobox at the top right of the
> code window, select New.

Yes, the constructor will be added after such actions.
But if I do not perform them, the constructor will be
implicitly addred by the compiler ?

Signature

Best regards,

Oleg Subachev

RobinS - 22 Apr 2007 08:52 GMT
If you add a Load event for your form, it will automatically put a call to
InitializeComponent() in the load, after which you can put any
initialization you want. You could also do it in a constructor for your
form.

Remember that the designer-generated code is regenerated whenever you
change your form, so changing it is not a great idea.

Robin S.
------------------------------------
> In VB.NET 2003 there is main form's constructor which
> contains InitializeComponent() call and a placeholder below
[quoted text clipped - 8 lines]
>
> Oleg Subachev
Oleg Subachev - 23 Apr 2007 07:27 GMT
> If you add a Load event for your form, it will automatically put a call to
> InitializeComponent() in the load

There is no InitializeComponent() call in the generated event handler.

> You could also do it in a constructor for your form.

Yes, this is what I want, but there is no automatically generated
constructor.

Signature

Best regards,

Oleg Subachev

RobinS - 24 Apr 2007 07:41 GMT
Sorry, my bad, not the Form_Load event. If you add a default constructor to
your form, it will add the InitializeComponent to it for you.

Try this: type in
 Public Sub New()
and hit return. It should fill it in like this:

   Public Sub New()

       ' This call is required by the Windows Form Designer.
       InitializeComponent()

       ' Add any initialization after the InitializeComponent() call.

   End Sub

Robin S.
--------------------------------
>> If you add a Load event for your form, it will automatically put a call
>> to InitializeComponent() in the load
[quoted text clipped - 5 lines]
> Yes, this is what I want, but there is no automatically generated
> constructor.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.