C#-MessageBox全部函数重载形式及举例

王朝学院·作者佚名  2016-05-16
窄屏简体版  字體: 小  |  中  |  大  |  超大  

C#-MessageBox全部函数重载形式及举例

Form1.cs

[csharp]view plaincopyusingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;namespaceMessageBoxTest1{publicpartialclassForm1:Form{publicForm1(){InitializeComponent();}/*AboutMessageBox.Show()*///Show(String):消息框包含消息并返回结果//Show(String,String)显示消息和标题栏//Show(Window,String)在指定的窗口前面显示消息框,显示消息并返回结果//Show(String,String,BoxButton)消息,标题栏,按钮,返回结果//Show(Window,String,String)在指定窗口前面显示消息框,消息,标题栏//Show(String,String,MessageBoxButton,MessageBoxImage)消息,标题栏,按钮,图标//Show(Window,String,String,MessageBoxButton)//Show(String,String,MessageBoxButton,MessageBoxImage)//Show(String,String,MessageBoxButton,MessageBoxImage,MessageBoxResult)//Show(Window,String,String,MessageBoxButton,MessageImage)//Show(String,String,MessageBoxButton,MessageBoxButton,MessageResult,MessageBoxOptions)遵循指定项返回结果//Show(Window,String,String,/*end*/PRivatevoidbutton1_Click(objectsender,EventArgse){DialogResultdr=MessageBox.Show("消息信息","标题",MessageBoxButtons.YesNoCancel);switch(dr){caseDialogResult.Cancel:MessageBox.Show("按下了Cancel");break;caseDialogResult.No:MessageBox.Show("按下了No");break;caseDialogResult.Yes:MessageBox.Show("按下了Yes!");break;}}}} Program.cs

[csharp]view plaincopyusingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Windows.Forms;namespaceMessageBoxTest1{staticclassProgram{///<summary>///应用程序的主入口点。///</summary>[STAThread]staticvoidMain(){application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Application.Run(newForm1());}}}Form1设计

[csharp]view plaincopynamespaceMessageBoxTest1{partialclassForm1{///<summary>///必需的设计器变量。///</summary>privateSystem.ComponentModel.IContainercomponents=null;///<summary>///清理所有正在使用的资源。///</summary>///<paramname="disposing">如果应释放托管资源,为true;否则为false。</param>protectedoverridevoidDispose(booldisposing){if(disposing&&(components!=null)){components.Dispose();}base.Dispose(disposing);}#regionWindows窗体设计器生成的代码///<summary>///设计器支持所需的方法-不要///使用代码编辑器修改此方法的内容。///</summary>privatevoidInitializeComponent(){this.button1=newSystem.Windows.Forms.Button();this.SuspendLayout();////button1//this.button1.BackColor=System.Drawing.Color.Lime;this.button1.Location=newSystem.Drawing.Point(82,39);this.button1.Name="button1";this.button1.Size=newSystem.Drawing.Size(117,23);this.button1.TabIndex=1;this.button1.Text="开始测试";this.button1.UseVisualStyleBackColor=false;this.button1.Click+=newSystem.EventHandler(this.button1_Click);////Form1//this.AutoScaleDimensions=newSystem.Drawing.SizeF(6F,12F);this.AutoScaleMode=System.Windows.Forms.AutoScaleMode.Font;this.BackColor=System.Drawing.Color.FromArgb(((int)(((byte)(255)))),((int)(((byte)(192)))),((int)(((byte)(192)))));this.ClientSize=newSystem.Drawing.Size(296,102);this.Controls.Add(this.button1);this.Name="Form1";this.Text="MessageBoxTest";this.ResumeLayout(false);}#endregionprivateSystem.Windows.Forms.Buttonbutton1;}}

 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
© 2005- 王朝網路 版權所有 導航