Link to home
Start Free TrialLog in
Avatar of nepaluz
nepaluzFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Unstable designer when I include a ToolStripCheckbox Class

Hello.
I want to add a CheckBox to a toolstrip and havebeen able to do this with the class below. I added the line
<ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.ToolStrip)> _

Open in new window

to have the CheckBox available in the designer, and this works. However, the designer is "unstable". I donot not know howelse to describe this, but, after adding the class below to the project, buttons already added to the project "at times" go missing from the designer or are in-accessible from the designer unless selected from the properties window. Infact, any further additions to the designer after compiling (and moving away from the designer then back) do not seem to "stick". Any ideas what is happening or on how toimplement this differently? I'd prefer to have the checkbox available in the designer. Here's is my entire class that is causing these issues.
Imports System.Windows.Forms.Design
<ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.ToolStrip)> _
Public Class ToolStripCheckBox
    Inherits ToolStripControlHost
    Public Sub New()
        MyBase.New(New CheckBox)
    End Sub
    Public ReadOnly Property CheckBoxControl As CheckBox
        Get
            Return TryCast(Control, CheckBox)
        End Get
    End Property
    Public Property Checked As Boolean
        Get
            Return CheckBoxControl.Checked
        End Get
        Set(ByVal value As Boolean)
            CheckBoxControl.Checked = value
        End Set
    End Property
End Class

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of nepaluz
nepaluz
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nepaluz

ASKER

I figured out the solution