When I click a button, a new form opens. How do I keep this form in the foreground when I click on another form?

StackOverflow https://stackoverflow.com/questions/23541066

Question

private void button1_Click(object sender, EventArgs e)
        {
            mtp1Start = myTrackPanelss1.Start;
            mtp1End = myTrackPanelss1.End;           
            button1.Enabled = false;
            Animation_Radar_Preview ap = new Animation_Radar_Preview();
            ap.FormClosing += new FormClosingEventHandler(ap_FormClosing);
            ap.Show();
        }

I want that the form ap will keep showing display even if i click on other button on the form behind it. I have one big form and when i click this button a smaller form is open. I want that the smaller form ap will keep showing stay on place when i click on the big form so the smaller form won't move to the back behind the big form.

Was it helpful?

Solution 2

try to show like this,

Animation_Radar_Preview ap = new Animation_Radar_Preview();
ap.FormClosing += new FormClosingEventHandler(ap_FormClosing);
ap.Show(this);

Assign the parameter this in Show() method. it will set the current form as a owner of child(ap).

OTHER TIPS

Set Form.TopMost property to true:

ap.TopMost = true;
ap.Show();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top