CLR Extender Reference

Walkthrough - Hosting a .NET control in a VFP Form

Description »

.NET Extender lets you use .NET Controls (any control derived from System::Windows::Forms::Control) in VFP Forms.

For this, it uses the class netBaseControl stored in netbasecontrols.vcx (located at HOME()+"tools\eTecnologiaNetExtender\classses") for the VFP counterpart. The process is transparent to you.

To host a .NET Control you:

  1. Put a instance of netBaseControl into the form where you want to host the .NET Control. And set one or two properties as explained below.
  2. Set the cControlClass property to the FullName of the System::Windows::Forms::Control derived class, that you want to host. For example: System::Windows::Forms::TreeView.
  3. If the Assembly where the type resides will not be in the Assembly Path at runtime, that is, if it has not been added with SetCLRClassLibrary, then you should specify where the type is available with the property cAssembly. For example: System.windows.forms.dll.

Then you can call the methods and access the properties available in the NET Control as if they were available in netBaseControl. For example, to access the Nodes property you write THISFORM.oTreeView.Nodes.

Additionally you can use CLRBindEvent to bind the .NET Events to the Form´s Methods or to the Control´s Methods. You can use the Assembly Browser to see the available events and the parameters needed. Usually the .NET Events require a method with two parameters toSource and toEventInfo.

Example »

A typical method to handle events would be:

PROCEDURE SomeEventHandler
LPARAMETERS toSource, toEventInfo
* See the documentation for info about toEventInfo
Remarks »

If you plan to bind several events it may be a better choice to subclass netBaseControl and to add methods to handle the events you wish to subscribe.


Send comments about this topic to eTecnologia.net.