C# - The MessageBox's

All tutorials created in C# to be posted in here.
5 posts Page 1 of 1
Contributors
User avatar
Agust1337
Coding God
Coding God
Posts: 2456
Joined: Fri Feb 19, 2010 8:18 pm

C# - The MessageBox's
Agust1337
Hello and welcome to my Messagebox's tutorial. I think the MessageBox function in C# is really hard to remember, so I want to let you people to make it not as hard to remember.

Simple MessageBox:
Code: Select all
MessageBox.Show("Some message")
Messagebox with Text & title
Code: Select all
MessageBox("This is the Text.", "This is the Title")
Messagebox with Yes and No buttons:
Code: Select all
DialogResult rslt = MessageBox.Show("Click Yes to do something and no to do something.", "Click Yes or No", MessageBoxButtons.YesNo);
if (rslt == DialogResult.Yes)
{
    //Do Something
}
else
{ 
    //If user hits No
}
Messagebox with Question Icon and Buttons:
Code: Select all
DialogResult rslt = MessageBox.Show("Do you want to do this? Click yes to do it and no to not too.", "Click Yes or No", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (rslt == DialogResult.Yes)
{
    //Do Something
}
else
{ 
    //If user hits No
}
Messagebox with Question Icon and Default Button:
Code: Select all
DialogResult rslt = MessageBox.Show("Do you want to do this? Click yes to do it and no to not too.", "Click Yes or No", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
if (rslt == DialogResult.Yes)
{
    //Do Something
}
else
{ 
    //If user hits No
}
Hope you liked this :)
Have a happy coding cooll;
Last edited by Agust1337 on Tue Apr 05, 2011 5:30 pm, edited 1 time in total.
You're crazy!
I'm not crazy, my mother had me tested. ~Sheldon Cooper
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: C# - The MessageBox's
mandai
I thought DialogResult was the return type of a MessageBox?
I don't see any objects under MessageBox.Buttons.
MessageBoxDeafultButton is spelt incorrectly.
User avatar
Agust1337
Coding God
Coding God
Posts: 2456
Joined: Fri Feb 19, 2010 8:18 pm

Re: C# - The MessageBox's
Agust1337
I will fix that maybe it was because I wrote it on the site not copied from C#
You're crazy!
I'm not crazy, my mother had me tested. ~Sheldon Cooper
User avatar
Jelly
Just Registered
Just Registered
Posts: 3
Joined: Tue May 10, 2011 11:41 pm

Re: C# - The MessageBox's
Jelly
Thanks for this release.
User avatar
mastercoderbb
Just Registered
Just Registered
Posts: 5
Joined: Thu Jun 30, 2011 2:47 am

Re: C# - The MessageBox's
mastercoderbb
Thanks for this amazing release might be useful XD
5 posts Page 1 of 1
Return to “C-Sharp Tutorials”