VB.NET 2005 newby question

  • Thread starter Thread starter Oleg Subachev
  • Start date Start date
O

Oleg Subachev

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
 
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
 
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.
 
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.
 
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 ?
 
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.
--------------------------------
 
Back
Top