Reputation: 20464
SCENARIO
I have a subclassed NumericDown like this:
Public Class MyNumericUpDown : Inherits NumericUpDown
' More code here that does not matter...
End Class
I would like to compile it as an UserControl
of a WindowsForms Control Library project to have the beneffit of the UserControl's property grid when debugging the project.
PROBLEM
I can't find the way to compile my NumericDown as I want without breaking the auto-generated Usercontrol
class of the WindowsForms Control Library project, this means, breaking the property grid feature and after compiling the project having a final exception message saying me that my dll: doesn't contain any UserControl types
(but really there is and I can add it into the VS control toolbox).
QUESTION
In C# or VB, how I can properly white an WindowsForms Control Library project to show only my custom NumericDown without loosing the property grid feature?
I hope you could understand what I want.
I'll try to say it in other words: I only would like to test my NumericUpDown in the property grid, not the usercontrol generated by default by the WindowsForms Control Library project.
It should be an "unit" when adding the dll into the VisualStudio control toolbox but instead that I get two separated controls.
CODE:
I don't have anything better to show because I can't find info to start doing this.
Public Class UserControl1 : Inherits UserControl
Public Sub New()
InitializeComponent()
' This is not what I want,
' or at least I think it shouldn't be done as normally like this,
' I only want to use and see my custom NumericUpDown on the property grid,
' not depending on any UserControl ControllCollection.
Me.Controls.Add(New MyNumericUpDown)
End Sub
End Class
Upvotes: 1
Views: 665
Reputation: 9981
The test application that is shipped with Visual Studio will only search for controls derived from UserControl. If you want it to be able to view/test other types then you need to create a custom application.
The following code is just a proof of concept. The easiest way to implement a full working application is to simply drop the UserControlTestContainer.exe
onto a decompiler like reflector and copy the code.
UserControlTestContainer
.enable application framework
and set the startup object
to sub main
.Public Class Form1
Public Sub New(Optional ByVal args As String() = Nothing)
Me.InitializeComponent()
Me.args = New Label With {.Dock = DockStyle.Fill, .Text = If((args Is Nothing), "(null)", String.Join(Environment.NewLine, args))}
Me.Controls.Add(Me.args)
End Sub
<STAThread()>
Public Shared Sub Main(Optional ByVal args As String() = Nothing)
Application.EnableVisualStyles()
Application.Run(New Form1(args))
End Sub
Private args As Label
End Class
UserControlTestContainer.exe
located in C:\Program Files (x86)\Microsoft Visual Studio {version}\Common7\IDE
with your custom UserControlTestContainer.exe
.Control
and hit run.Upvotes: 1