I have form1(frmGate) and form2 (frmEdit)

form1 minimizes when form2 is open and restores when form2 is closed

however I use this to open form2

private void btnEdit_Click(object sender, EventArgs e)
        {
            //checks to see if the form is open
            if (editor == null || editor.IsDisposed == true)
            {
                editor = new frmEdit();
                editor.InstanceRef = this;
            }
            // Loads edit windows for selected Dealer
            editor.dealerBindingSource.DataSource = this.dealerBindingSource;
            editor.dealerBindingSource.CurrencyManager.Position = Convert.ToInt32(dealerBindingNavigator.PositionItem.Text);
            this.WindowState = FormWindowState.Minimized;
            editor.Show();
        }

but frmEdit does not come to front
it is on desktop not minmized but comes up behind browser and such...

tried to add frmEdit _Shown event

private void frmEdit_Shown(object sender, EventArgs e)
        {
            //Make form  active
            this.Activate();
            this.BringToFront();
        }

and

private void frmEdit_Shown(object sender, EventArgs e)
        {
            //Make form  active
            this.TopMost = true;
            this.Focus();
            this.BringToFront();
            this.TopMost = false;
        }

and still it wont come to front...
I set frmEdit TopMost property to true in designer and removed the top line in code above but then it will not set the topmost to false and is always on top...

I even tried the above code in the frmEdit_Load event and no joy

Cant seem to understand why this is happening
Any help would be much appreciated

Upload a project demonstrating the issue. If you call BringToFront() and it pumps the message before the window is finished maximizing/restoring sometimes it won't bring the application up front, it will only cause the application to start blinking in the task bar. [edit] The reason I say upload a project is because there are a few form/control settings that can cause the behavior to change [/edit]

I've never uploaded a project here how would i go about that and the project utilizes a mysql db so it may not work elsewhere until i learn how to wrap the db into the project.

replaced frmEdit_Shown with frmEdit_Activated and viola she works...
I dont understand it but as long as it works and code is not bloated I'm happy :)

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.