A MessageBox is a predefined dialog box that displays application-related information to the user. Message boxes are also used to request information from the user.
To display information to the user in a message box
Navigate to where you would like to add the code for the message box.
Add code using the MessageBox.Show method.
The following code demonstrates how to call the Show method of the MessageBox class to display information to the user. The call to the Show method uses the optional style parameter to specify the type of icon to display in the message box that best fits the type of message box being displayed:
public void PerformCalculations()
{
// Code is entered here that performs a calculation
// Display a message box informing the user that the calculations
// are complete
MessageBox.Show ("The calculations are complete", "My Application",
MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
}
Message boxes can also receive input. The Show method of the MessageBox class returns a value that can be used to determine a choice made by the user. You can store this value in an integer or compare the value returned when you display the message box using an if statement. The Style parameter of the Show method can be set to display the proper buttons to ask a user for information.
Displaying Message Boxes in C#
Теги
cmessage boxlearn cbegin cstart cc begginersMessage box in cc desktop applicationeasy cc in 15 daysLessonsBasicTutorialsc programingc programmingc tuningc tutorialc programming tutorial.net developerc beginnerc introductionprogramming ctutorial ccsharpadvance cc inputmessage queuinghtml message boxinfinite message boxtext message breakupautomatic message box