By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,163 Members | 1,432 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,163 IT Pros & Developers. It's quick & easy.

User control displaying class property implementing IList interfac

P: n/a
Hi
I have a user control that has a property which is a class implementing IList:
public partial class MultiPanelControl : UserControl
{
protected MultiPanelList _panels = new MultiPanelList();
...
}

public class MultiPanelList : IList<MultiPanel>
{
...
}

At design time I want to be able to view this property in the property grid
and have the good old (Collection) with a button displayed and then editable.
My attempts have led to various effects, but none are the one required.

Thanks for any help anyone can provide.

Marek

Mar 30 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi Marek,

Thanks for your post!

You may create a customized CollectionEditor for IList<MultiPanel>, and
then specify the customized CollectionEditor for the property like this:
[Editor(typeof(MyCustomizedCollectionEditor),
typeof(System.Drawing.Design.UITypeEditor))]

Note: in MyCustomizedCollectionEditor class, you should return MultiPanel
type as the item type in

public class CustomCollectionEditor :
System.ComponentModel.Design.CollectionEditor CreateNewItemTypes() method,
like this:
{
private Type[] types;
public CustomCollectionEditor(Type type)
: base(type)
{
types = new Type[]{typeof(MultiPanel)};
}

// Return the types that you want to allow the user to add into your
collection.
protected override Type[] CreateNewItemTypes()
{
return types;
}
}

Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 31 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.