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