Object Collection Editor

  • Thread starter Sergio Florez M.
  • Start date
S

Sergio Florez M.

I created a button control that I'll call MyButton. I also created a
composite control that will have among other things a toolbar composed of
MyButtons. Let's call this control MyCompositeControl. I want the
MyCompositeControl to have a Buttons property that will be a MyButton
collection. I created a MyButtonsCollection inheriting from CollectionBase
and implementing IEnumerable. The Buttons property in MyCompositeControl is
a MyButtonsCollection.

My control already admits Buttons and this is more or less how it all looks
in the aspx:

<xxx:MyCompositeControl id="MyCompositeControl1" runat="server>
<Buttons>
<xxx:MyButton ID="MyButton1" SomeProperty="111"></xxx:MyButton>
<xxx:MyButton ID="MyButton2" SomeProperty="222"></xxx:MyButton>
<xxx:MyButton ID="MyButton3" SomeProperty="333"></xxx:MyButton>
</Buttons>
</xxx:MyCompositeControl>

What do I have to do to get the Object Collection Editor that opens up when
I click the "..." button that shows up in the properties pane for the
Buttons property to add MyButton objects to it?

One other question, MyCompositeControl look fine in design time until I
start with the <Buttons> tag, once I start adding buttons I get "Error
creating control" in the designer. How do I fix this?

The functionality of the control is all up and running, these are just
designer issues that I want to comprehend.

Is any of this understandable at all?
 
P

Paul K

As far as the Buttons property, I have done similar projects and never had to
do anything special. The standard collection editor opens when I clicked on
the ellipses and I am able to add objects without a problem. Are you seeing
the ellipses in the property grid?

As far as the problem rendering the control, it might be how you are
rendering the control when it has buttons in it -- if you use the
RenderControl method in your designer you'll have to make sure you wrap any
references to runtime-only objects (such as Page) in if blocks to make sure
you're not trying to use an object that doesn't exist.

What I normally do is just be an exception handler in the designer and
output the stack trace. This can narrow the problem down pretty quickly.
 

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,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top