I'm posting here because I'm not too sure Google will take the entire search criteria of what I'm trying to explain.

I have a Main form, called Main.vb, that is a Parent Form. I have another form called Notes.vb.

Inside Main.vb I have a toolstrip with a button on it called Notes. I'm wanting to change the checked status of the Button to either True when the Notes.vb window is open inside the parent or to false when it is close.

Is this possible?

When you open or close the Notes form, check or uncheck the ToolStrip button. To handle the case where the user closes the form manually, simply add this in the FormClosing event handler:

DirectCast(Me.Parent, [B][i]TypeOfParentForm[/i][/B]).[B][i]NameOfToolStripButton[/i][/B].Checked = False

I'm a little confused by the TypeOfParentForm. What exactly do I put there?

When I do the following, I get an error.

DirectCast(Me.Parent, HOME).ToolStripButton1.Checked = False

Unable to cast object of type 'System.Windows.Forms.MdiChild' to type 'Proj.Home'.

See if this helps to add a Toggle Button Control to the ToolStrip and respond as needed.
2 Forms, 1 ToolStrip(on Form1)

Public Class Form1
    '// New CheckBox. (Appearance.Button changes a CheckBox to a Toggle Button)
    Public WithEvents cbNotes As New CheckBox With {.Width = 75, .Text = "Notes", .Appearance = Appearance.Button, .Cursor = Cursors.Hand}

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '//--- Add CheckBox to ToolStrip.
        Dim myCtlHost As New ToolStripControlHost(cbNotes)
        ToolStrip1.Items.Add(myCtlHost) '---\\
    End Sub

    Private Sub cbNotes_CheckStateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbNotes.CheckStateChanged
        If cbNotes.Checked Then
            Form2.MdiParent = Me
            Form2.Show()
        Else
            Form2.Close()
        End If
    End Sub
End Class
Public Class Form2

    Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If Form1.cbNotes.Checked Then Form1.cbNotes.Checked = False '// uncheck when closing.
    End Sub
End Class

If you just want to use a Button on the ToolStrip, see if this helps.

Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        With ToolStripButton1
            If Not .Checked Then
                Form2.MdiParent = Me
                Form2.Show()
                .Checked = True '// Check Button.
            Else
                Form2.Close()
                .Checked = False '// UnCheck Button.
            End If
        End With
    End Sub

So where are you "doing the following"? In the parent form? It is meant to be run in the child form... could you post your project structure, I'll tell you which file you should use the code in.

Ok, where you put HOME you should put Main , which I suppose is the name of the parent's class

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.