.NET grouping forms so that pulling up the primary form shows all other forms?
I have an app that can open up some other forms at the user's request, and they're set to not show in the taskbar. The problem is, if one of the secondary windows becomes hidden by another app, switching to the primary window only brings that form to the forefront.
Is there a good way to "group" the forms so that giving any of them focus brings the whole group to the front? I tried calling BringToFront()
on each form in the primary form's Activated
event, 开发者_JAVA百科but that also gives the secondary forms focus, making it impossible to interact with the primary form.
You have to set your main form as owner of the other forms. Tested with this code snippet:
Private Sub addNextForm(ByVal sender As Object, ByVal e As EventArgs)
Dim newForm As New Form()
newForm.StartPosition = FormStartPosition.CenterParent
newForm.Text = "Form " & Me.OwnedForms.Length + 1
newForm.ShowInTaskbar = False
newForm.Owner = Me
Dim btn As New Button()
btn.Text = "Open Form"
AddHandler btn.Click, AddressOf Me.addNextForm
newForm.Controls.Add(btn)
newForm.Show()
End Sub
精彩评论