)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to add a Windows Forms GridControl in Visual Basic 6.0?

Platform: WinForms |
Control: GridControl |
Published Date: April 27, 2016 |
Last Revised Date: May 28, 2019
Tags: hosting, vb6.0

To add a Windows Forms grid control in Visual Basic 6.0 we should follow the below steps.

Step 1: Create new WF library project.

Step 2: Add form and necessary control to the project.

Step 3: Include below class libraries for InterOp functions.

Adding InterOP function

using System.Runtime.InteropServices;
using System.Text;
using System.Reflection;
using Microsoft.Win32;

Step 4:  Need to register Com objects, below code snippet in class file for com registration.

Com file

 

[ComRegisterFunction()]
public static void RegisterClass ( string key )
{
StringBuilder      sb = new StringBuilder ( key ) ;
sb.Replace(@"HKEY_CLASSES_ROOT\","") ;
RegistryKey k    = Registry.ClassesRoot.OpenSubKey(sb.ToString(),true);
RegistryKey ctrl = k.CreateSubKey ( "Control" ) ;
ctrl.Close ( ) ;
RegistryKey inprocServer32 = k.OpenSubKey ( "InprocServer32" , true )  ;
inprocServer32.SetValue ( "CodeBase" ,Assembly.GetExecutingAssembly().CodeBase );
inprocServer32.Close ( ) ;
k.Close (  ) ;
}
[ComUnregisterFunction()]
public static void UnregisterClass ( string key  )
{
StringBuilder  sb = new StringBuilder ( key ) ;
sb.Replace(@"HKEY_CLASSES_ROOT\","") ;
RegistryKey  k =  Registry.ClassesRoot.OpenSubKey(sb.ToString(),true);
k.DeleteSubKey ( "Control" , false ) ;
RegistryKey  inprocServer32 = k.OpenSubKey (  "InprocServer32" , true   ) ;
k.DeleteSubKey ( "CodeBase", false ) ;
k.Close( );
}

Step 5:  Need to check COM object visibility in Properties -> Application -> Assembly Information -> Check Make assembly COM – visible.

Step 6:  Need to check register for COM interop via Properties -> Build -> Register for COM interop.

Step 7:  Rebuild the application and generate project assembly.

Step 8: Open visual studio command prompt as administrator. And execute below command.

Regasm “Assembly file path”  for example [“C:/GaugeWF.dll”]
regasm “Assembly file path” /regfile:GaugeWF.reg
regasm “Assembly file path” /tlb: GaugeWF.tlb
regasm  /codebase “Assembly file path”

By following above steps generated assembly will be registered in local machine and so it will be exposed as ActiveX control. And it can have tested via opening it in VS ActiveX control test container.

Step 9: For testing functionality, Open Active-X test container in below location.

C:\Program Files (x86) \Microsoft Visual Studio 8\Common7\Tools\tstcon32.exe

Step 10: Select Edit -> Add New Control -> above control will be available in this location and by double clicking on it, that will be integrated in VBA container.

 

Showing Grid control in Visual Basic

Sample:

VB: Windows forms grid control in VB6.0

Video:

Windows forms grid control in VB6.0

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon