Message Box
MessageBox is used to display a message to the user. MessageBox displays a message and provide buttons that user can use to give a response. The syntax is as follows,
MessageBox(prompt,[buttons],[title])
Prompt:- It is a string that should appear in the message box or it is the actual message we want to give to the user.
Buttons:- The type of buttons and icons to appear in the message box should be specified here. It is an optional argument as MessageBox shows OK button by difult. The optional arguments for buttons and icons are as follows,
Constants value Description ------------------------------------------------------------------------------------ OKOnly 0 Displays only OK button. OKCancel 1 Displays OK and Cancel buttons. AbortRetryIgnore 2 Displays Abort,Retry and Ignore buttons. YesNoCancel 3 Displays Yes, No and Cancel buttons. YesNo 4 Displays Yes and No buttons. Exclamation 48 Displays an exclamation icon.
There are several other constants for icons like Information, Error, Abort,etc.
Title:- The string passed will be displayed as the title of the message box.
Example:-
MessageBox.Show("Want to Continue?",MessageBoxStyle.YesNoCancel+MessageBoxStyle.Exclamation,"Information")
The above example will display a message box with Yes, No and Cancel buttons with an exclamation icon containing the message 'Want to Continue?'.
We can also use the integer values for specifying the button and icon as follows,
MessageBox.Show("Want to Continue?",51,"Information") Here 51 specifies the addition of button value and icon value(3+48)
|
No responses found. Be the first to respond and make money from revenue sharing program.
|