I've made an app with vb 2010, which holds a mainform. On it is a menutoolstrip with button, when I click on that button a second form is opened on a second monitor and the button is being checked (different color).
When I click the button again, it is unchecked, but the form on the second monitor is still open, while it should be closed.
Here is the code I use:
Hope someone can help me with this?
Thanks
When I click the button again, it is unchecked, but the form on the second monitor is still open, while it should be closed.
Here is the code I use:
VB.NET:
Private Sub ButtonItem16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem16.Click
If ButtonItem16.Checked = True Then
ButtonItem16.Checked = False
Else
ButtonItem16.Checked = True
End If
End Sub
Private Sub ButtonItem16_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem16.CheckedChanged
Dim screen As Screen
Dim scfrm As New Form
Dim lab As New Label
If screen.AllScreens.Length > 1 Then
If ButtonItem16.Checked = True Then
scfrm.Controls.Add(lab)
lab.Dock = DockStyle.Fill
'Show the form on second screen
screen = screen.AllScreens(1)
scfrm.StartPosition = FormStartPosition.Manual
scfrm.Location = screen.Bounds.Location + New Point(100, 100)
scfrm.Show()
scfrm.WindowState = FormWindowState.Maximized
scfrm.FormBorderStyle = Windows.Forms.FormBorderStyle.None
scfrm.BackColor = Color.Black
Else
scfrm.Close()
End If
Else
MsgBox("No extended screen found, dual video needs an extended screen.")
ButtonItem16.Checked = False
End If
End Sub
Hope someone can help me with this?
Thanks