Articles in this section
Category / Section

How to add WinForms GridControl to VB 6.0?

2 mins read

Steps for Grid control to VB 6.0

Using ActiveX control support we can add WinForms Grid Controls in VB 6.0. WinForms .NET controls can be added to VB 6.0 by converting the WinForms .NET controls as ActiveX control and the following steps guides the same.

Step 1: Create new WinForms library project.

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

Step 3: Include below class Libraries for Interop functions.

C#

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

 

Step 4:  Need to register COM objects. Please include the following code snippet in class file for COM registration.

C#

[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.

Register for COM interop

Step 7:  Rebuild the application and generate project assembly.

Samples:

C#: C_Sharp_ActiveX_Derived Control

VB: VB_ActiveX_Derived Control

 

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

Step 8: For testing functionality, Open Active-X test container from the following location.

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

Location of tstcon32 setup

 

Step 9: Select Edit -> Add/Insert New Control.

Adding new comment

 

Step 10: Above control will be available in this location.

Adding the control

 

Step 11: By double clicking on it that will be integrated in VBA container as below.

VBA container

 

Note:

Similarly, all Syncfusion WF controls can be added to VB 6.0.

 

Conclusion

I hope you enjoyed learning about how to add WinForms GridControl to VB 6.0.

You can refer to our WinForms Grid Control feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. 

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied