Native .NET Core WinForms Grid Control - iGrid.NET

by Igor Katenov, the lead developer at 10Tec

Microsoft claimed support for Windows Forms applications in .NET Core in 2018. As you may already know, the Redmond software giant fulfilled its promises and added Windows Forms support in the release version of .NET Core 3.0 published on September 30th, 2019. We were waiting for this release too to test our flagship WinForms grid control, iGrid.NET, with the official release of .NET Core 3.0 and amend the source code of the grid if required to be fully compatible with .NET Core. And it happened – now we have a native .NET Core WinForms grid control!

The word 'native' in the preceding sentence means that iGrid.NET can be recompiled for .NET Core 3.0 so that you can use it as a .NET Core-based grid control in .NET Core WinForms apps without .NET Framework installed on the pc:

.NET Core WinForms grid control example

Fortunately, the source code did not require a lot of changes. Actually we changed the code snippets related to graphic resource loading to be compatible with the new .NET Core infrastructure. All graphic resources like icons and cursors are loaded from the embedded iGrid resources using the following function:

internal static System.IO.Stream GetResourceStream(string resourceName)
  return Assembly.GetExecutingAssembly().GetManifestResourceStream(
    "TenTec.Windows.iGridLib.Resources." + resourceName);

A usage example:

Cursor fCursorResizeRow = new Cursor(GetResourceStream("ResizeRow.cur"));

The .NET Core project file of the iGrid.NET control was re-created from scratch to be compatible with the new MSBuild format used in .NET Core. The essential part of the project file for .NET Core looks like this:

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
    <EmbeddedResource Include="Resources\ResizeRow.cur" />
    <!-- embedding other resources -->

The project file became simpler and shorter compared to its Windows Forms .NET Framework counterpart. But what is also important, we could share the existing source code base with the new .NET Core platform. We provide the same source code for .NET Framework and .NET Core with the full version of the product and you can recompile it for the required target runtime just by opening the corresponding solution in Visual Studio.

The Windows form and the .NET Core grid on the picture at the beginning of this article was created with the following code:

public partial class Form1 : Form
  public Form1()

  private iGrid fGrid;

  private void Setup_iGrid()
    fGrid = new iGrid();

    fGrid.RowHeader.Visible = true;

    fGrid.Cols.Add("col1", "Column 1");
    fGrid.Cols.Add("col2", "Column 2");


    fGrid.DefaultRow.Height = fGrid.GetPreferredRowHeight(true, false);
    fGrid.Rows.Count = 5;

    fGrid.Cells[0, 0].Value = "Abc";
    fGrid.Cells[1, 0].Value = 123;

    fGrid.Dock = DockStyle.Fill;

As you can see, the grid control was created and added to the form completely from code because of the limitations of the Windows Forms designer for .NET Core apps. This tool was in beta on the moment of writing this article and allowed us to work only with a limited set of the intrinsic visual controls:

Introducing .NET Core Windows Forms Designer Preview 1

We could not see how our grid control compiled for .NET Core looks on the Visual Studio Toolbox and whether its design-time functionality works in this new environment. We hope that eventually Microsoft will improve its Windows Forms designer in .NET Core projects and we will be able to check the design-time functionality of iGrid.NET in it. In any case, we are going to continue supporting of our WinForms grid to be a first-class lightweight and powerful native grid control on the .NET Core WinForms platform.

Find out more about 10Tec WinForms grid control »