Windows Forms: How To Use Metro Framework Metro Style Manager in C#

By FoxLearn 6/20/2017 9:49:46 PM   16.64K
How To Use Metro Style Manager in C# using Metro Framework, Modern UI

Step 1Click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "MetroStyle" and then click OK

metro style managerStep 2: Right click on your project select Manage NuGet Packages -> Search metro framework -> Install

install metro frameworkIf you don't see the metro framework in your toolbox, you can view How to download and install metro framework

Step 3: Design metro form as below

c# metro ui

Step 4: Add code to handle your metro form as below

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MetroStyle
{
    public partial class Form1 : MetroFramework.Forms.MetroForm
    {
        public Form1()
        {
            InitializeComponent();
            //Set style manager
            this.StyleManager = metroStyleManager1;
        }

        private void mbTheme_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Select metro theme
            switch (mbTheme.SelectedIndex)
            {
                case 0:
                    metroStyleManager1.Theme = MetroFramework.MetroThemeStyle.Dark;
                    break;
                case 1:
                    metroStyleManager1.Theme = MetroFramework.MetroThemeStyle.Light;
                    break;
            }
        }

        private void mbColor_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Select metro color
            metroStyleManager1.Style = (MetroFramework.MetroColorStyle)Convert.ToInt32(mbColor.SelectedIndex);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            mbColor.SelectedIndex = 0;
            mbTheme.SelectedIndex = 0;
        }
    }
}

VIDEO TUTORIALS