Pass Variable At Design Time

  • Thread starter Thread starter Derek Hart
  • Start date Start date
D

Derek Hart

I have a custom control with a property defined as follows. The UITypeEditor
is a Windows Form called MergeFieldNameBuilder. How do I pass a variable to
this form from this property? Cannot figure out how to set a global variable
from here, or some other way to pass it in.

<Editor(GetType(MergeFieldNameBuilder),
GetType(System.Drawing.Design.UITypeEditor))> _
Public Property DataField() As String
Get
Return _DataField
End Get
Set(ByVal value As String)
_DataField = value
End Set
End Property
 
You can keep the variable you want to pass as a member of the class defining
the DataField property. One of your MergeFieldNameBuilder overriden methods
will get pased an instance of the class, from which you can access the
variable.

---------
- G Himangi, LogicNP Software http://www.ssware.com
Shell MegaPack: Drop-In GUI Controls For Windows Explorer Like File And
Folder Browser Functionality
CryptoLicensing: Add licensing, copy-protection and activation to your
software
EZNamespaceExtensions: Fast and painless development of namespace extensions
EZShellExtensions: Rapid development of all shell extensions,explorer bars
and BHOs
 
The type editor can access any public method property in your class to edit
by accessing/typecasting the value parameter of the type editor EditValue
method e.g.

public class StringListTypeEditor : UITypeEditor
{
// Methods
public override object EditValue(ITypeDescriptorContext context,
IServiceProvider provider, object value)
{
object dResult = null;
if (((context != null) && (context.Instance != null)) && (provider !=
null))
{
IWindowsFormsEditorService edSvc =
provider.GetService(typeof(IWindowsFormsEditorService)) as
IWindowsFormsEditorService;
if (edSvc == null)
{
return dResult;
}
StringListEditor dEdit = new StringListEditor();
CaptionsList dVal = (CaptionsList) value; //<=== your object giving all
methods and properties
.......
 
Back
Top