Home All Groups Group Topic Archive Search About

Pass Variable At Design Time

Author
10 Jun 2009 11:06 PM
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

Author
11 Jun 2009 5:48 AM
G Himangi
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
---------

Show quoteHide quote
"Derek Hart" <derekmh***@yahoo.com> wrote in message
news:u8rNeAi6JHA.1712@TK2MSFTNGP03.phx.gbl...
>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
>
>
>
Are all your drivers up to date? click for free checkup

Author
11 Jun 2009 5:54 AM
Horst Reichert
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
.......

Bookmark and Share