10Tec Company

MSFlexGrid in VB.NET/C# and Its Equivalent, iGrid

Edited by

Using outdated Microsoft FlexGrid in VB.NET and C#

If you read this article, most likely, you know the old good grid control MSFlexGrid which comes with the so called classic Visual Basic (VB6). Microsoft replaced VB6 with VB.NET and Windows Forms package with the release of its .NET Framework. Fortunately for all us, we still have the ability to add Microsoft FlexGrid to the VB.NET toolbox and use it in modern releases of Visual Studio like 2010 or 2012. Here is a screenshot of the corresponding Choose Toolbox Item dialog when adding MSFlexGrid to VB.NET 2010:

Adding MSFlexGrid to VB.NET Toolbox
(Click to Enlarge)

The MSFlexGrid toolbox item with the text "Microsoft FlexGrid Control, Version 6.0 (SP6)" becomes available, and you can use it to create an instance of MSFlexGrid on a WinForms form and edit the FlexGrid properties using the ActiveX control property pages:

VB.NET WinForms designer with an MSFlexGrid

MS FlexGrid OCX (MSFLXGRD.OCX) was developed in the previous century without taking into account Microsoft's future .NET Framework, so be ready to use special syntax for FlexGrid's properties and methods when coding in VB.NET or another .NET language. For instance, you need to use special get_ and set_ methods instead of indexed properties as the .NET Framework does not support this syntax directly. Here is a sample code in which we exploit the ColWidth(colindex) and TextMatrix(rowindex, colindex) properties of MSFlexGrid to set the width of the first column and place a string in an MSFlexGrid cell:

AxMSFlexGrid1.set_ColWidth(0, 1500)
AxMSFlexGrid1.set_TextMatrix(0, 0, "abc")

Pay attention that you specify item sizes in so called logical twips but not in pixels like in .NET (1500 in our sample, which equals 100 pixels when the default 96 DPI is in effect). This will bring you some inconvenience when coding in VB.NET/C#.

However, more complex style of coding is not the worst thing when you try to use MSFlexGrid in VB.NET. Microsoft FlexGrid does not guarantee full compatibility with VB.NET and C# .NET development environments. This means you may encounter some minor glitches or more serious problems with MSFlexGrid in VB.NET/C#.

The main source of all possible problems when using MSFlexGrid in VB.NET is the COM technology it is based on. For example, some developers encountered improper cell image drawing in .NET (see this link regarding using FlexGrid's CellPicture property with native .NET images).

The COM (ActiveX) base of MSFlexGrid gives you some more troubles with redistributing your app if it uses MSFlexGrid OCX. It is not enough to copy the MSFlexGrid OCX, MSFLXGRD.OCX, together with your app like we do that for native .NET DLL assemblies, you also need to register it as a COM control on your user's pc - and potentially face such problems as admin access, etc when doing this. If you go this way though, the topic VB.net MSFlexGrid Solution! on the vbCity forums can help you to solve some problems with redistributing MSFlexGrid with your .NET apps.

Add to this that the outdated MSFlexGrid does not support the visual styles available in latest releases of MS Windows - you'll have that old 3D look (like on the screenshot above) which is inconsistent with other modern WinForms controls. And don't forget that MSFlexGrid OCX is 32-bit and it does not work in 64-bit environments.

MSFlexGrid VB.NET/C# equivalent and more - 10Tec iGrid

Our WinForms grid control, iGrid.NET, is free from all the drawbacks mentioned above when you use it in C# or VB.NET instead of MSFlexGrid. It's a native .NET Framework control built and optimized specially for this platform. It is fully compatible with both 32- and 64-bit editions of Microsoft Windows and has the same look-and-feel like the standard OS components (the OS's visual style is used automatically).

There is no need to duplicate the description of the benefits and advantages of 10Tec WinForms grid here as it is done in the product's section on this website. If you are searching for an equivalent of MSFlexGrid in VB.NET or another development environment based on the .NET Framework, use the link below to find out more about our iGrid.NET:

More info about iGrid.NET, a VB.NET MSFlexGrid equivalent »