網(wǎng)站模板更換營(yíng)銷廣告語
信息提示框是一個(gè)非常普遍的應(yīng)用,C#的提示框位于System.Windows.Forms.MessageBox,在使用時(shí),可以利用using System.Windows.Forms便直接寫為MessageBox,在MessageBox中,存在著各種各樣的使用方法,將非常方便界面設(shè)計(jì),并且能將界面制作的比較友好。
1.??一個(gè)參數(shù),直接給出提示
MessageBox.Show(string text);
// 顯示具有指定文本的消息框。
// 參數(shù):
// text:???? 要在消息框中顯示的文本。
// 返回結(jié)果:???? System.Windows.Forms.DialogResult 值之一。
MessageBox.Show("? 1? 個(gè)參數(shù) ");
2.??兩個(gè)參數(shù),改變標(biāo)題選項(xiàng)????????????????????
?MessageBox.Show(string text, string caption);
//???? 顯示具有指定文本和標(biāo)題的消息框。
// 參數(shù):
//?? text:????? 要在消息框中顯示的文本。
//?? caption:???? 要在消息框的標(biāo)題欄中顯示的文本。
// 返回結(jié)果:????? System.Windows.Forms.DialogResult 值之一。
MessageBox.Show(" 2個(gè)參數(shù)。。","亮仔提示");
3.??三個(gè)參數(shù),控制按鈕顯示,不再是簡(jiǎn)單的OK按鈕,按鈕位于MessageBoxButtons
MessageBox.Show(string text, string caption, MessageBoxButtons buttons);
//???? 顯示具有指定文本、標(biāo)題和按鈕的消息框。
// 參數(shù):
//?? text:????? 要在消息框中顯示的文本。
//?? caption:???? 要在消息框的標(biāo)題欄中顯示的文本。
//?? buttons:???? System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中顯示哪些按鈕。
// 返回結(jié)果:???? System.Windows.Forms.DialogResult 值之一。
MessageBox.Show(" 3個(gè)參數(shù)。。。"," 亮仔提示",????????????????????????????MessageBoxButtons.YesNoCancel);
?
4.??四個(gè)參數(shù),在提示界面顯示各種圖標(biāo),圖標(biāo)位于MessageBoxIcon
MessageBox.Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon);
//???? 顯示具有指定文本、標(biāo)題、按鈕和圖標(biāo)的消息框。
// 參數(shù):
//?? text:???? 要在消息框中顯示的文本。
//?? caption:???? 要在消息框的標(biāo)題欄中顯示的文本。
//?? buttons:???? System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中顯示哪些按鈕。
//?? icon:???? System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中顯示哪個(gè)圖標(biāo)。
// 返回結(jié)果:???? System.Windows.Forms.DialogResult 值之一。
?
MessageBox.Show(" 4個(gè)參數(shù)。。。? ", " 亮仔提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning);
?
5.??五個(gè)參數(shù),直接定位按鈕,缺省按鈕位于MessageBoxDefaultButton中
MessageBox.Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton);
//???? 顯示具有指定文本、標(biāo)題、按鈕、圖標(biāo)和默認(rèn)按鈕的消息框。
// 參數(shù):
//?? text:????? 要在消息框中顯示的文本。
//?? caption:???? 要在消息框的標(biāo)題欄中顯示的文本。
//?? buttons:???? System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中顯示哪些按鈕。
//?? icon:???? System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中顯示哪個(gè)圖標(biāo)。
//? ?default Button:???? System.Windows.Forms.MessageBoxDefaultButton 值之一,可指定消息框中的默認(rèn)按鈕。
// 返回結(jié)果:???? System.Windows.Forms.DialogResult 值之一。
MessageBox.Show(" 5個(gè)參數(shù)。。 。? "," 亮仔提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning,MessageBoxDefaultButton.Button2 );
6.??六個(gè)參數(shù),可以設(shè)置界面參數(shù)
MessageBox.Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon,MessageBoxDefaultButton defaultButton, MessageBoxOptions options);
//???? 顯示具有指定文本、標(biāo)題、按鈕、圖標(biāo)、默認(rèn)按鈕和選項(xiàng)的消息框。
// 參數(shù):
//?? text:????? 要在消息框中顯示的文本。
//?? caption:???? 要在消息框的標(biāo)題欄中顯示的文本
//?? buttons:??? System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中顯示哪些按鈕。
//?? icon:???? System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中顯示哪個(gè)圖標(biāo)。
//?? defaultButton:???? System.Windows.Forms.MessageBoxDefaultButton 值之一,可指定消息框中的默認(rèn)按鈕。
//?? options: System.Windows.Forms.MessageBoxOptions 值之一,可指定將對(duì)消息框使用哪些顯示和關(guān)聯(lián)選項(xiàng)。若要使用默認(rèn)值,請(qǐng)傳入0。
// 返回結(jié)果:???? System.Windows.Forms.DialogResult 值之一。
?
MessageBox.Show(" 6個(gè)參數(shù)。。。? "," 亮仔提示",MessageBoxButtons.OKCancel, MessageBoxIcon.Warning,MessageBoxDefaultButton.Button2, MessageBoxOptions..RightAlign )
7.??七個(gè)參數(shù),顯示Help內(nèi)容,直接給出在線幫助
MessageBox.Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon,MessageBoxDefaultButton
//???? 顯示一個(gè)具有指定文本、標(biāo)題、按鈕、圖標(biāo)、默認(rèn)按鈕、選項(xiàng)和“幫助”按鈕的消息框。
// 參數(shù):
//?? text:????? 要在消息框中顯示的文本。
//?? caption:???? 要在消息框的標(biāo)題欄中顯示的文本。
//?? buttons:???? System.Windows.Forms.MessageBoxButtons 值之一,可指定在消息框中顯示哪些按鈕。
//?? icon:???? System.Windows.Forms.MessageBoxIcon 值之一,它指定在消息框中顯示哪個(gè)圖標(biāo)。
//?? defaultButton:???? System.Windows.Forms.MessageBoxDefaultButton 值之一,可指定消息框中的默認(rèn)按鈕。
//?? options:???? System.Windows.Forms.MessageBoxOptions 值之一,可指定將對(duì)消息框使用哪些顯示和關(guān)聯(lián)選項(xiàng)。若要使用默認(rèn)值,請(qǐng)傳入0。
//?? helpButton:???? 如果顯示“幫助”按鈕,則為 true;否則為 false。默認(rèn)為 false。
// 返回結(jié)果:???? System.Windows.Forms.DialogResult 值之一。
?
MessageBox.Show(" 7個(gè)參數(shù)。。幫助菜單不可用。。。。。? ", " 亮仔提示",MessageBoxButtons.OKCancel, MessageBoxIcon.Warning,MessageBoxDefaultButton.Button2, MessageBoxOptions.RightAlign, true);
MessageBox.Show(" 7個(gè)參數(shù)。幫助菜單??? 可用。?? ", " 亮仔提示",MessageBoxButtons.OKCancel, MessageBoxIcon.Warning,MessageBoxDefaultButton.Button2, MessageBoxOptions.RightAlign? ,??@"C:\Documents and Settings\Administrator\桌面\新建文本文檔.txt");
最后,再說一下MessageBox的返回值, 返回值表示選擇了哪個(gè)按鈕,返回值在DialogResult中。