I have a MDI form which opens a docked child form (user dashboard) that is not closable by the users. The MDI can then open up either docked child forms within the MDI or non docked child forms. The problem I am running into is that if the user opens a customer info docked form and they hit save on that form, after the save it switches to the dashboard form automatically. on load and loading the dashboard
'Display Main Dashboard in MDI Dim fc As FormCollection = Application.OpenForms Dim FormFound As Boolean = False For Each frm As Form In fc If frm.Name = "frmDashboard" Then frm.Focus() FormFound = True End If Next If FormFound = False Then Dim frm As New frmDashboard With frm .MdiParent = Me '.Dock = DockStyle.Fill .FormBorderStyle = FormBorderStyle.Fixed3D .WindowState = FormWindowState.Maximized .Show() _log.Info("Opening the dashboard form") End With End If
If user calls the customer form
Private Sub tsbCustVend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsbCustVend.Click Try tvNavigation.Enabled = False Me.Cursor = Cursors.WaitCursor Dim fc As FormCollection = Application.OpenForms Dim FormFound As Boolean = False For Each frm As Form In fc If frm.Name = "frmCustomer" Then frm.Focus() FormFound = True End If Next If FormFound = False Then Dim CustForm As New frmCustomer _log.Info("Opening form " & CustForm.Name) With CustForm .MdiParent = Me '.Dock = DockStyle.Fill .FormBorderStyle = FormBorderStyle.Sizable .WindowState = FormWindowState.Maximized End With CustForm.Show() End If Catch ex As Exception _log.Error(ex.ToString & vbCrLf & ex.StackTrace.ToString) MessageBox.Show(ex.ToString, "", MessageBoxButtons.OK, MessageBoxIcon.Error) Finally Me.Invalidate() tvNavigation.Enabled = True Me.Cursor = Cursors.Default End Try End Sub
After the user save a new or existing customer the background dashboard form is brought the the front and focused. Any help is appreciated Thanks
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)