471,337 Members | 939 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

CollectionEditor - Strange behavior: overriden SetItems not being called

Hi!

I'm using a custom collection with custom items to be edited with a custom
CollectionEditor. This set of functionality is to be a part of a plugin for
a SharpDevelop-based application.
The strange thing now is that my derived CollectionEditor's SetItems method
is called when testing the collection editing within a small test
application,
but is NOT called when tested from within the SharpDevelop environment.
Thus whenever I add collection items by clicking Add in the CollectionEditor
window and then click OK to save those new items, these are lost within
the SharpDevelop application.
What is the reason for SetItems to be called upon clicking the OK button in
the CollectionEditor window? And what might be the reason for SetItems not
being called although I have modified collection items?

This is the code I'm using:

// This is one single custom item within the collection.
public class Label
{
private string m_Language;
private string m_Value;

[Category ("Attribute")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Visible)]
public string Language
{
get
{
return m_Language;
}
set
{
m_Language = value;
}
}
[Category ("Attribute")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Visible)]
public string Value
{
get
{
return m_Value;
}
set
{
m_Value = value;
}
}
}

// This is the custom collection containing objects of type "Label".
public class Labels : CollectionBase
{
// ... (contents omitted for brevity) ...
}
// This is my editor for the Label collection
public class LabelsEditor : CollectionEditor
{
private Type[] m_Types;

public LabelsEditor (Type type) : base(type)
{
m_Types = new Type[] {typeof (Label)};
}

protected override Type[] CreateNewItemTypes()
{
return m_Types;
}

protected override Type CreateCollectionItemType()
{
return typeof (Label);
}

protected override object CreateInstance(Type ItemType)
{
Label l = (Label) base.CreateInstance (typeof (Label));
return l;
}

protected override object SetItems(object editValue, object[] value)
{
base.SetItems (editValue, value);
return editValue;
}
}
What needs to be done to make the CollectionEditor call the SetItems method
in any case? Sorry for possibly being a bit unspecific but I have no idea
where to check for hints about CollectionEditor showing different behaviors.

Thanks,
Andreas
Jan 9 '06 #1
0 1481

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by m. pollack | last post: by
9 posts views Thread by Karahan Celikel | last post: by
reply views Thread by m. pollack | last post: by
reply views Thread by m. pollack | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.