Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bring form back to top

Status
Not open for further replies.

djam

Technical User
Nov 15, 2002
223
CA
I have a main form with a save button, when the save button is pressed a MessageBox asks if they would like to save or not. When I select Yes or No I can't seem to get the main form to the top again. If I have other windows opened the main form is put in the background. I've tried this.Focus(), this.BringToFront()


private void btn_Save_Click(object sender, System.EventArgs e)
{
DialogResult result;
result = MessageBox.Show("Save changes?", "Save changes", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);

// update text fields with currentRow data
if(result == DialogResult.Yes)
{
//<does the saving>
}
this.Focus();
}

&quot; ahhh computers, how they made our lives much simpler ;) &quot;
 
Hey, I haven't tried, but you may look into zorder...or possibly hwnd, though there may be easier ways to do it.

Good luck,
Kevin

- "The truth hurts, maybe not as much as jumping on a bicycle with no seat, but it hurts.
 

you could try making the MessageBox modal to the form using MessageBox.Show(this, "..."...)


mr s. <;)

 
finally got it... i used activate() before or after the messagebox and it keeps the form on top.

&quot; ahhh computers, how they made our lives much simpler ;) &quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top