Article

Example: Making a hidden control within a .NET application accessible to Studio

To make a hidden control within a .NET application accessible to Studio, you must call the CreateHandle method of the control. CreateHandle is a protected method so you will need to invoke it using reflection. This code invokes CreateHandle using reflection:

// Must specify Instance and NonPublic MethodInfo info = typeof(Control).GetMethod( "CreateHandle", BindingFlags.Instance | BindingFlags.NonPublic); info.Invoke(txtCreateHandle, new object[] {});

The public method, CreateControl, also states that it will force the creation of a window. However, the CreateControl method will not work if a control is not visible. The remarks section states:

CreateControl does not create a control handle if the control's Visible property is false. You can either call the CreateHandle method or access the Handle property to create the control's handle regardless of the control's visibility, but in this case, no window handles are created for the control's children.

Published December 6, 2016 — Updated February 7, 2017


100% found this useful

Have a question? Get answers now.

Visit the Pega Support Community to ask questions, engage in discussions, and help others.