Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to auto hide message box?

Tags:

c#

I want a timer type of property for message boxes. After displaying error, it must disappear without user intervention after 5 seconds.

like image 468
RKh Avatar asked Nov 24 '10 18:11

RKh


People also ask

How do I exit a messagebox window?

Application.ApplicationExit += new EventHandler ( Application_Exit ); Alternatively, if you have a handle to the MessageBox window, you could send the MessageBox window a WM_CLOSE message. (You can obtain the handle to the MessageBox window using FindWindow.)

How do I set a timer for a message box?

Sub MessageBoxTimer () Dim AckTime As Integer, InfoBox As Object Set InfoBox = CreateObject ("WScript.Shell") 'Set the message box to close after 10 seconds AckTime = 10 Select Case InfoBox.Popup ("Click OK (this window closes automatically after 10 seconds).", _ AckTime, "This is your Message Box", 0) Case 1, -1 Exit Sub End Select End Sub

How to show/hide the updated record in MsgBox?

ActiveCell.Offset(0, 1).Select ActiveCell.Value = CustomerProblem Sheets("sheet1").Select Range("C4").Select Msgbox "Record Updated " should be showed & hide at once (Without clicking ok) End Sub This thread is locked.

What happens if no one clicks on the message box?

If no one clicks a button within 10 seconds, the message box will automatically dismiss itself. Message box title. Message box type: a message box with Yes and No buttons and a question mark icon. When we call the Popup method the message box appears on screen.


1 Answers

timer.Interval=5000;
timer.Enabled=true;
MessageBox.Show("Should close automatically");

Associate the following snippet with the timer's Tick eventhandler:

private void timer_Tick(object sender,EventArgs evt) {
    timer.Enabled=false;
    SendKeys.Send("{ESC}"); // SendWait as alternative
}
like image 129
bcosca Avatar answered Oct 05 '22 09:10

bcosca