Windows Forms: Metro GridView in C#

This tutorial will show you how to use a Metro Gridview with Metro Framework, then use Entity Framework to retrieve data from sql database in C#

As you know, Metro Framework is an open source library that helps you design a modern awesome ui

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

metro gridview

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

install metro framework

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

Step 3: From your visual studio toolbox drag a MetroLabel, MetroTextbox, MetroGridView, MetroButton to your window form, then design your form as below

metro gridview

Right click on your project select Add -> New Item -> ADO.NET Entity Data Model -> Select Northwind database -> Products table

If you haven't got Northwind database, you can view How to download and restore Northwind database in SQL Server

Step 4: You need to change the inheritance from the Form to the MertroForm, then add code to handle button click event as he following

public partial class Form1 : MetroFramework.Forms.MetroForm
{
    public Form1()
    {
        InitializeComponent();
        //Init theme, style
        this.StyleManager = metroStyleManager1;
        metroStyleManager1.Theme = MetroFramework.MetroThemeStyle.Light;
        metroStyleManager1.Style = MetroFramework.MetroColorStyle.Green;
    }

    private void btnLoad_Click(object sender, EventArgs e)
    {
        using (NorthwindEntities db = new NorthwindEntities())//Create an instance for data context
        {
            productBindingSource.DataSource = db.Products.ToList();
        }
    }
}

VIDEO TUTORIALS