DataGridView MetroFramework Source Code


DataGridView MetroFramework Source Code

If you already seen or read one of my blog post here regarding my DataGridView MetroFramework that I created using C1Flexgrid and Winforms-Modern UI metro framework, you’ll probably interested on how I created it and somehow you want get a copy of the source code.
I created this function because currently there is no DataGridView MetroFramework available inside the Winforms-Modern UI metro framework that you is available on Github. And DataGridView is a one of the commonly used control when creating desktop applications, it is an easy way to display and manipulate list of information that is broken up into columns and row just like in excel.
C1FlexGrid is one of the popular and most powerful DataGridView that is available in the market, you can check and grab a trial version from ComponentOne web site. Luckily our company got a license of ComponentOne winform control and I got chance to play around with it and come up with a function that will match the theme of Winforms-Modern UI metro framework. I didn’t include this function in my version of Winforms-Modern UI metro framework because not all programmers have a copy of C1Flexgrid of Component and this will probably give an error :
So without further ado let’s start checking the code:
In my project I created a class folder and added MetroGrid.cs class and I inherit C1FlexGrid and IMetroControl

using MetroFramework.Components;
using MetroFramework.Interfaces;
using MetroFramework.Controls;
using MetroFramework;

namespace DataGridMetro.Class
public partial class MetroGrid : C1FlexGrid, IMetroControl

I added two MetroScrollBar, one is for horizontal and the other one is for vertical, and on the initialization we need attached event handlers for scroll and other events of C1Flexgrid that we need to manipulate.

public MetroGrid()

scrollhelper = new MetroGridHelper(_vertical, this);
scrollhelperH = new MetroGridHelper(_horizontal, this, false);

this.RowColChange += MetroGrid_RowColChange;
this.BeforeScroll += MetroGrid_BeforeScroll;
this.AfterScroll += MetroGrid_AfterScroll;
this.AfterFilter += MetroGrid_AfterFilter;
this.AfterDataRefresh += MetroGrid_AfterDataRefresh;
this.DoubleClick += MetroGrid_DoubleClick;
this.KeyDown += MetroGrid_KeyDown;

if (this.Rows.Count > 1)
Rectangle _rec = this.GetCellRect(this.Row, 0);
int _left = _rec.Left;
int _top = _rec.Top;

_horizontal.MouseLeave += Metro_MouseLeave;
_vertical.MouseLeave += Metro_MouseLeave;

Continue on next page

Liked it? Take a second to support denricdenise on Patreon!

You may also like...