|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Pass Variable At Design TimeI 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 --------- 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 > > > 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 .......
Other interesting topics
Design Time Controls
Cannot use Mustinherit in a base form System.Windows.Forms.Control.Handle==HWND? static classes are evil ? Project consisting of multiple projects Saving and retrieving WinForm template info Read From Application Config File In Class Library Form transparency Win forms designer - controlling the designer code generation What control did Microsoft Use? |
|||||||||||||||||||||||