Pass Variable At Design Time

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
 
G

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
 
H

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
.......
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top