I think this is an easy one!

A

active

I have the following at the start of a class.

Seems to me I could delete everything except the New method.

Is that correct?

I can't imagine why not but since the IDE put it there I'd like some
reassurance.



Thanks



Inherits System.Windows.Forms.ComboBox

#Region " Windows Form Designer generated code "

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

Public Sub New()

MyBase.New()

InitializeComponent()

End Sub

'UserControl1 overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If (components IsNot Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

Me.SuspendLayout()

Me.ResumeLayout(False)

End Sub

#End Region
 
C

Cor Ligthert [MVP]

Active,

Yes,

With a shared class as well the new method, but in my eyes is that no class.

Cor
 
P

Phill W.

active said:
I have the following at the start of a class.
Seems to me I could delete everything except the New method.
Is that correct?
No.

Inherits System.Windows.Forms.ComboBox
This says that your class inherits from ComboBox. That means it "looks"
and "acts" like a ComboBox (i.e. you can put it on a Form and it will
"appear", you can add items to it, etc., etc.). Without this, your
class inherits from Object, which can;t do any of that.
#Region " Windows Form Designer generated code "
You /could/ consider removing this, but don't be surprised if the Forms
Designer puts it back in!
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
Take this out and you won't be able to "edit" your Control in the
Designer any more.
Public Sub New()
MyBase.New()
InitializeComponent()
End Sub
OK, /this/ you need.
'UserControl1 overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
. . .
End Sub
All of this seems to be required for your Control to get "tidied" up in
the /same/ way as every /other/ Windows Control.
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor. Hah!

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.SuspendLayout()
Me.ResumeLayout(False)
End Sub
I'd be surprised if this is /all/ you have in here - the Designer likes
to dump all sorts of properties in here, almost for fun.
#End Region
See #Region

HTH,
Phill W.
 
A

active

Thanks Phill

Phill W. said:
This says that your class inherits from ComboBox. That means it "looks"
and "acts" like a ComboBox (i.e. you can put it on a Form and it will
"appear", you can add items to it, etc., etc.). Without this, your class
inherits from Object, which can;t do any of that.

You /could/ consider removing this, but don't be surprised if the Forms
Designer puts it back in!

Take this out and you won't be able to "edit" your Control in the Designer
any more.

OK, /this/ you need.

All of this seems to be required for your Control to get "tidied" up in
the /same/ way as every /other/ Windows Control.

I'd be surprised if this is /all/ you have in here - the Designer likes to
dump all sorts of properties in here, almost for fun.

See #Region

HTH,
Phill W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top