Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
I have a custom control deriving from Panel, let's call it CPanel. One of CPanel's public properties is a List<Button>, called ButtonList. When CPanel is dropped on a form, all CPanel's public properties are shown in the "usual" property grid in VS Studio (2013). The ButtonList property shows in the property grid with ellipses (...) also, as usual. Clicking on the ellipses correctly invokes my custom CollectionEditor with its own property grid allowing me to add, move items up/down, and delete them. Selecting a Button within the list also shows all the standard properties of the Button much the same as editing a single button dropped on a form would be shown.

However, unlike the usual property grid for a single button dropped on a form which also has an Events tab for assigning various methods to, say, the Click event, the custom CollectionEditor property grid does not show the Events tab for a button item.

How do I show the events tab within the CollectionEditor's property grid so I can wire up events to the items in the ButtonList as usual?

This is purely a design-time question/issue. I have no problem creating ButtonList items, getting them persisted, getting Cpanel notified that the list has been changed, etc. I just can't get the Events tab displayed.
Posted
Comments
Sergey Alexandrovich Kryukov 28-Jan-15 17:34pm    
This is very unclear. How can we suggest anything without knowing what your CollectionEditor already does, especially its custom property grid. Not clear what's wrong with PropertyGrid (yes, it's not easy to customize, but this is doable). If you already designed your own property grid, how can you ask such questions without appropriate information on it?
—SA
ozbear 28-Jan-15 17:52pm    
Well, I didn't design my own property grid, I just use the one supplied by the CollectionForm. My ColllectionEditor is virtually identical to the one at http://dotnetfacts.blogspot.com.au/2008/05/how-to-take-control-over-collection.html

First, I congratulate you for getting as far as you have in the esoteric business of creating a custom CollectionEditor !

And, I hesitate to discourage you, but this is something I looked into a few years ago, and gave up on. Even expensive commercial PropertyGrid substitutes, like the one from VisualHint, will not expose the Event Tab in the way you (and I) would like.

I found the PropertyGrid not only "finicky" to work with, but the resources for solving this problem ... how to show Events ... not very clear. My estimation of the amount of time and energy to get this feature implemented indicated it was not worth the "opportunity cost" of getting other, more important things, done.

I could show you how to "break" Visual Studio 2013 in under three minutes by creating a UserControl that was a host to custom Components (inheriting from Button, or whatever), and putting a public Property in the custom Component of Type List&Button>. That's discouraging for this type of experimentation.

However, "a few years ago" is a very long time in techno-time: it appears to me there might be a recent breakthrough for useful information in this area ... this month ... in this (long) post on StackOverFlow: [^].

I don't have time right now to really explore Plutonix's code on this post, but I look forward to doing so, and hope it is useful to you.

If you do work this out, I'd really appreciate seeing a CodeProject article, or Tip-Trick from you in the future !
 
Share this answer
 
Comments
ozbear 29-Jan-15 15:55pm    
Thank you, Bill, for understanding the crux of the problem/issue.
Oz
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900