Articles in this section

How to Add Windows Forms in Visual Basic 6.0 by WinForms GridControl?

To add our WinForms GridControl in Visual Basic 6.0, we should follow the steps below.


Step 1: Create a new WF library project.

Step 2: Add form and necessary controls 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, code snippet below in the 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 the register for COM interop via Properties -> Build -> Register for COM interop.


Step 7:  Rebuild the application and generate the project assembly.


Step 8: Open Visual Studio Command Prompt as administrator. And execute the command below.

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 the above steps generated assembly will be registered in the local machine, and so it will be exposed asan  ActiveX control. And it can be tested by opening it in the VS ActiveX control test container.


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

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 the VBA container.

 

Showing Grid control in Visual Basic

Sample:

VBWindows Forms grid control in VB6.0

 

Video:

Windows Forms grid control in VB6.0


Conclusion

I hope you enjoyed learning about how to add Windows Forms in Visual Basic 6.0 with WinForms GridControl.


You can refer to our WinForms GridControl feature tour page to know about its other groundbreaking feature representations and WinForms GridControl 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 forums, Direct-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)
Access denied
Access denied