MessageBox.Show Method in C# - C# Desktop application tutorial
Описание
To access the full course in order, click on the link below:-
https://www.youtube.com/watch?v=hb6ZnMdN70k&list=PL3xn38RVdvf4e1zaw88Hc-HKsiSJmox3n
What is MessageBox show in C#?
Is MessageBox show a modal dialog window?
What is difference between MsgBox and MessageBox?
What does MessageBox return?
How do I display message box?
What is MessageBox show in C#?
What is a message box windows?
Message box C#
c# message box show
Message Box
C# message box Yes/No
message box c# example
wpf message box
Message box in vb Net
message box c# stack overflow
MessageBox.Show():
MessageBox is a class in C# and Show is a method that displays a message in a small window in the center of the Form.
MessageBox is used to provide confirmations of a task being done or to provide warnings before a task is done.
Create a Windows Forms app in Visual Studio and add a button on it. Something like this below.
Example
Let's say, you want to show a message on a button click event handler. Here is the code for that.
OUTPUT
Note: By default the OK Button will be shown.
DialogResult
DialogResult is an enumeration of the possible return values of a dialog box including a MessageBox. The Show method returns a DialogResult that tells us what button a user has clicked on the message box.
public static System.Windows.Forms.DialogResult Show (string text);
Here are the values of DialogResult:
Abort - The dialog box return value is Abort (usually sent from a button labeled Abort).
Cancel - The dialog box return value is Cancel (usually sent from a button labeled Cancel).
Ignore - The dialog box return value is Ignore (usually sent from a button labeled Ignore).
No - The dialog box return value is No (usually sent from a button labeled No).
None - Nothing is returned from the dialog box. This means that the modal dialog continues running.
OK - The dialog box return value is OK (usually sent from a button labeled OK).
Retry - The dialog box return value is Retry (usually sent from a button labeled Retry).
Yes - The dialog box return value is Yes (usually sent from a button labeled Yes).
For example, if you want to ask a user to close a form on a Yes button click of a message box, you can do something like this:
Form1.cs code:
private void button1_Click(object sender, EventArgs e)
{
DialogResult d;
d=MessageBox.Show("Welcome to C# Corner","Learn C#", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if(d==DialogResult.Yes)
{
Close();
}
}
source
https://www.c-sharpcorner.com/UploadFile/736bf5/messagebox-show
Рекомендуемые видео



















