How to create a Metro Message Box in C#
By FoxLearn 11/16/2024 2:29:51 AM 24.69K
How to create a Metro Message Box in C#?
To create a Metro MessageBox using the Metro Framework Modern UI Design in C# Windows Forms, you'll first need to ensure that you have the Metro Framework installed in your project.
You can install it via NuGet Package Manager by right-clicking on your project, then select Manage NuGet Packages -> Search metro framework -> Install
Once you have the Metro Framework installed, you can follow these steps to create a Metro MessageBox:
Next, Drag and drop the MetroTile control from the Visual Studio toolbox to your winform, then you can design a simple dashboard as shown below.
If you haven't got the metro framework toolbox, you can view the post how to download and install metro framework to visual studio toolbox
To create a metro form, then change inheritance from Form to the MetroForm
You can now use this method to show Metro-styled message boxes throughout your application as the following c# code.
//OK message box private void metroTile1_Click(object sender, EventArgs e) { MetroFramework.MetroMessageBox.Show(this, "OK", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } //Yes/No message box private void metroTile3_Click(object sender, EventArgs e) { if (MetroFramework.MetroMessageBox.Show(this, "Yes/No", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //Do something } } //YesNo/Cancel message box private void metroTile2_Click(object sender, EventArgs e) { if (MetroFramework.MetroMessageBox.Show(this, "YesNo/Cancel", "Message", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) { //Do something } } //Error message box private void metroTile4_Click(object sender, EventArgs e) { MetroFramework.MetroMessageBox.Show(this, "Error", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } //Warning message box private void metroTile5_Click(object sender, EventArgs e) { MetroFramework.MetroMessageBox.Show(this, "Warning", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } //Hand message box private void metroTile6_Click(object sender, EventArgs e) { MetroFramework.MetroMessageBox.Show(this, "Hand", "Message", MessageBoxButtons.OK, MessageBoxIcon.Hand); } //Stop message box private void metroTile7_Click(object sender, EventArgs e) { MetroFramework.MetroMessageBox.Show(this, "Stop", "Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Stop); } //None message box private void metroTile8_Click(object sender, EventArgs e) { MetroFramework.MetroMessageBox.Show(this, "None"); }
Through the c# example above, you've learned how to use metro ui framework to create Metro MessageBox types in c# .net windows forms application.
VIDEO TUTORIAL
- How to use Modern UI Metro Framework in C#
- How to Create CPU and Memory Monitor using Metro Modern UI in C#
- How to Create a Metro Modern Flat UI Dashboard in C#
- How to Download and Install Metro Framework
- How To Use Metro Framework Metro Style Manager in C#
- How to Create a Modern Windows 8 UI with the Metro Framework in C#
- How to create a Metro Wait Form in C#
- How to use Metro Progress Bar in C#