Hi Michael,
How about your problem now?
I have read through the 3 approaches, the latter two seems similiar with
the autogenerated code.
I think they should work. However, the first approach may have a little
defect, if an exception raised in method DoDirtyThings, the instantiation
will fail. If you really need to this, you must be sure that you handled
the exception properly.
If you still have problem on this issue, please send me a small but
complete project to reproduce your problem.I'll work on it to see if I can
find the problem.
Thanks!
Best regards,
Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!
--------------------
| From: "Michael Reimann" <
[email protected]>
| References: <#
[email protected]>
<
[email protected]>
| Subject: Re: PRB: Combobox inheritance and Form designer
| Date: Tue, 14 Oct 2003 11:02:04 +0200
| Lines: 132
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <
[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: dsl-62-220-11-28.berlikomm.net 62.220.11.28
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:54375
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| I was trying different alternatives, but I allways started with a standard
| combobox and then I replaced in the designer section the automatically
| generated type information by hand. Because the outer class does not
change
| between the alternatives, it's only shown in the first section.
|
|
| 1) ********
|
| #Const DisableForDesignerMode = True
|
| Public Class MyForm
| Inherits System.Windows.Forms.Form
|
| Private Class MyComboBox
| Inherits System.Windows.Forms.ComboBox
| Public Sub New()
| MyBase.New()
| DoDirtyThings()
| End Sub
| #If Not DisableForDesignerMode Then
| ' Properties
| ...
| #End If
| Public Sub DoDirtyThings()
| #If Not DisableForDesignerMode Then
| ' Initialisation
| ...
| #End If
| End Sub
| End Class
|
| 'designer part snip
| ...
| Private WithEvents cbMyBox As MyProject.MyForm.MyComboBox
| ...
| Private Sub InitializeComponent()
| ...
| Me.cbMyBox = New MyProject.MyForm.MyComboBox
| ...
| Me.AnyControl.Controls.Add( Me.cbMyBox )
| ...
| End Sub
| 'end designer part snip
| ...
| End Class
|
|
| 2) ********
|
| Private Class MyComboBox
| Inherits System.Windows.Forms.ComboBox
| Public Sub New()
| MyBase.New()
| End Sub
| Protected Overrides Sub RefreshItem(ByVal index As Integer)
| MyBase.RefreshItem(index)
| End Sub
| Protected Overrides Sub SetItemCore(ByVal items As
| System.Collection.IList)
| MyBase.SetItemCore(items)
| End Sub
| End Class
|
| 'designer part snip
| ...
| Private WithEvents cbMyBox As MyProject.MyForm.MyComboBox
| ...
| Private Sub InitializeComponent()
| ...
| Me.cbMyBox = New MyProject.MyForm.MyComboBox
| ...
| Me.AnyControl.Controls.Add( Me.cbMyBox )
| ...
| End Sub
| 'end designer part snip
|
|
| 3) ********
|
| Private Class MyComboBox
| Inherits System.Windows.Forms.ComboBox
| Private components As System.ComponentModel.Container = Nothing
| Public Sub New(ByVal Container As System.ComponentModel.IContainer)
| MyClass.New()
| Container.Add(Me)
| End Sub
| Public Sub New()
| MyBase.New()
| InitializeComponent()
| End Sub
| Private Sub InitializeComponent()
| components = New System.ComponentModel.Container
| End Sub
| Protected Overrides Sub RefreshItem(ByVal index As Integer)
| MyBase.RefreshItem(index)
| End Sub
| Protected Overrides Sub SetItemCore(ByVal items As
| System.Collection.IList)
| MyBase.SetItemCore(items)
| End Sub
| End Class
|
| 'designer part snip
| ...
| Private WithEvents cbMyBox As MyProject.MyForm.MyComboBox
| ...
| Private Sub InitializeComponent()
| ...
| Me.cbMyBox = New MyProject.MyForm.MyComboBox(Me.components)
| ...
| Me.AnyControl.Controls.Add( Me.cbMyBox )
| ...
| End Sub
| 'end designer part snip
|
| ************
|
| These different flavours resulted in a quick "research" in the internet
and
| my hope that one of it will get it working. By the way, without switching
to
| the designer the code is running.
| The error message is in german and says (from my memory) something like:
| cbMyBox is not declared or instanciated
| failed to create an instance of MyProject+cbMyBox because of an error
| happened in MyProject.Global
| "Global" is the name of a modul in my Project, but there are no references
| to that inside of MyComboBox.
| And for now at last ... I'm shure I've forgotten to tell you something.
|
| With best Regards
| Michael
|
|
|