Unstable designer when I include a ToolStripCheckbox Class

Posted on 2011-10-23
Last Modified: 2012-05-12
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
            Return TryCast(Control, CheckBox)
        End Get
    End Property
    Public Property Checked As Boolean
            Return CheckBoxControl.Checked
        End Get
        Set(ByVal value As Boolean)
            CheckBoxControl.Checked = value
        End Set
    End Property
End Class

Open in new window

Question by:nepaluz
    LVL 17

    Accepted Solution

    OK. I figured this one out. I was NOT putting the class in the form where I put the checkboxes. Putting the code under the form's class solved the issues I had.
    LVL 17

    Author Closing Comment

    I figured out the solution

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
    This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
    The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now