L
lucianoluke
Hi all,
I am trying to have a collection serialized to a property of the parent
control in HTML.
The collection items are controls found in the page. When the designer
is being loaded, My TypeConverter.ConvertFrom is called. The problem is
that ITypeDescriptorContext context is null.
I tryied creating a ControlDesigner and overriding
DesignTimeHtmlRequiresLoadComplete to always return true; No good. The
ConvertFrom is called BEFORE my ControlDesigner constructor's is even
called.
Is there any spell that I can cast to solve this problem?
my property attributes are:
Notice that I dont want to have InnerProperties and the like. I want my
control data string stored in a property.
Thanks for any input that may help.
Luciano Bargmann
I am trying to have a collection serialized to a property of the parent
control in HTML.
The collection items are controls found in the page. When the designer
is being loaded, My TypeConverter.ConvertFrom is called. The problem is
that ITypeDescriptorContext context is null.
I tryied creating a ControlDesigner and overriding
DesignTimeHtmlRequiresLoadComplete to always return true; No good. The
ConvertFrom is called BEFORE my ControlDesigner constructor's is even
called.
Is there any spell that I can cast to solve this problem?
my property attributes are:
Code:
-----------------------------------------
[Description("The tabs displayed on this control")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[PersistenceMode(PersistenceMode.Attribute)]
[TypeConverter(typeof(TabCollectionTypeConverter))]
[Editor(typeof(TabCollectionUITypeEditor), typeof(UITypeEditor))]
public TabCollection TabPanels
{
get
{
object tabs = this.ViewState["TabPanels"] as
TabCollection;
if (tabs != null)
{
return (TabCollection) tabs;
}
return new TabCollection();
}
set
{
this.ViewState["TabPanels"] = value;
}
}
------------------------------------------------------
TabCollectionTypeConverter
public override object ConvertFrom(ITypeDescriptorContext context,
CultureInfo culture, object value)
{
TabCollection tc = new TabCollection();
if (context != null && value is string)
{
string[] v = ((string)value).Split(new char[] {','});
foreach (string s in v)
{
ComponentCollection components =
context.Container.Components;
foreach (IComponent component in components)
{
if (!(component is Control))
{
continue;
}
HPTabPanel ctrl =
(HPTabPanel)component;
if ((ctrl.ClientID != null) &&
(ctrl.ClientID.Length != 0) &&
ctrl.ClientID == s)
{
tc.Add(ctrl);
}
}
}
}
return tc;
}
------------------------------------- UITypeEditor
public override object EditValue(ITypeDescriptorContext context,
IServiceProvider provider, object value)
{
if (provider != null)
{
IWindowsFormsEditorService editorService =
(IWindowsFormsEditorService)
provider.GetService(typeof(IWindowsFormsEditorService));
if (editorService == null)
{
return value;
}
// get forms editor service
IWindowsFormsEditorService wfes =
provider.GetService(typeof(IWindowsFormsEditorService)) as
IWindowsFormsEditorService;
// create our form
TabCollectionEditorForm form = new
TabCollectionEditorForm(context,
value as TabCollection);
// show our form
wfes.ShowDialog(form);
// Force designer update
context.OnComponentChanged();
// return updated value
return form.Tabs;
}
// just in case
return base.EditValue(context, provider, value);
}
------------------------------
Notice that I dont want to have InnerProperties and the like. I want my
control data string stored in a property.
Thanks for any input that may help.
Luciano Bargmann