How to make Editor for ListItemCollection visible in VS2005 properties page?

C

cpnet

I'm trying to build a User Control in C# for ASP.NET 2.0. My user control
contains two ListBoxes. I am exposing the Items property of each ListBox as
public properties of my User Control. That part works ok. But, I can't get
a collection editor to show for the items properties of my User Control.
How can I do this? Here's what I'm trying so far:


[EditorBrowsable(EditorBrowsableState.Always)]
[Editor("System.ComponentModel.Design.CollectionEditor",
typeof(System.Drawing.Design.UITypeEditor)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public ListItemCollection Items1
{
get
{
return ListBox1.Items;
}
}


I see my "Items1" property in the property page in VS2005 at design time,
but the button to open up the collection editor is not there. I've tried
different combinations of the attributes above to no avail. What am I doing
wrong? Does ListItemCollection have a default Editor that should just show
up if I don't include any attributes (this doesn't happen for me)?

Thanks,
cpnet
 
W

Walter Wang [MSFT]

Hi cpnet,

Due to how the UserControl is designed to work within the VSIDE, I don't
think it's possible to achieve your objective here. I think you will need
to create a custom server control (a composite control) to do that. Though
this requires much code change. Please let me know if you need further
information on how to do this with a custom server control.


Regards,
Walter Wang ([email protected], remove 'online.')
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.
 
C

cpnet

Hi Walter,

I was beginning to suspect that this was the case. I've built server
controls before so I should be ok to do that. I was just hoping to use a
user control because this is just something quick and dirty for a prototype.

Thanks,
cpnet
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top