Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Normally, there is 'Color' property in PropertyGrid, when user click the icon at the end of 'value' item of property, the PropertyGrid object will automatically support the dedicated color dialog for this 'Color' property for user to edit the color data.

My questions are :

<1> How can I get the control when clicking this icon, so that I can open the ColorDialog instead of the build-in color dialog ?

<2> In general, I would like to get the control when clicking this icon for such as Boolean property, Font property etc., can anyone provide any solution or detailed reference code ? Thanks.
Posted

1 solution

I already answered a similar Question. This is not easy, but doable. Please see this Question and my Answer: How to get response when click PropertyGrid[^]. (See my "long" Answer.)

Please don't say my Answer is irrelevant from the first glance: it is relevant, but the ideology of PropertyGrid is maybe very different from what you might expect. The idea is not modifying the behavior if this control. Instead, you should create you own control(s) to embed in the grid. To use them, you need to create a special data type to wrap your real data. You should assign an instance of your wrapper data type to the property PropertyGrid.Selected object instead of reference to your "real" data object.

Nevertheless, this approach can be very universal: you can develop your customized controls and the wrapper the way it will suite nearly all data classes/structures you need. Don't think you need to repeat this work for every specific data type.

—SA
 
Share this answer
 
v2
Comments
Sports Kuo 8-Mar-11 2:49am    
=============================================
Thanks so much of your comments.
May I have some questions below :
1> I've read your previous 'long answer', I seems understand, but also may not understand it completely. Could you provide some kind of completedly workable and simple code including all the related structure(such as interface declaration and implementation etc...) ?
Since I may can not put all together by myself, as to ask for Microsoft help, it seems be not easy, since the infomration from Microsoft web site can be very speratedly. (not be integrated with whole reference code to easily understand)
2> At the end of your previous answer, you mentioned that “For a complete course on my enumeration techniques please see my series of three CodeProject articles on Enumeration topics, please find them in my CodeProject profile”, may I know Which keywords should I input ? (I've input keywords "Enumeration", it shows tree articles with your worderful name, however, the content of articles seems be not related to my question ?
Thanks again.
Sergey Alexandrovich Kryukov 8-Mar-11 3:38am    
(1) Providing my code is not easy at all. I did it and though to publish as an article, but it will take a lot of time and effort. And the code is much bigger than the usual library. And I have other publication waiting in line. Sorry to say, I cannot afford changing my priority, so I'm afraid you would wait way too long time. At the same time, you can follow my line of directions, read help on each API I cited and implement the code. It could be even faster than a derivative work from my code, because your requirements can be very different. Seriously, it could be faster. Also, if you have problem down the road, I might be able to help with some.

(2) Why searching anything by keywords? I'll just tell you. I don't have so many Article on CodeProject. Click on my profile ("SAKryukov" HREF above this comment), on that page click "Articles" and you will see. Three last Article on Enumeration, the last one have 3 references as well. How it is related? In my original code I needed a very important customization of Properties to show and edit enumerations properly and in human readable way. Later I refined the technique in my new works on enumerations published in the mentioned Articles.

Will you formally accept my Answer?
I'll tell you, anyway, there is no any other way except creating your own PropertyGrid control from scratch based on Reflection (quite a different approach)...

--SA
Sports Kuo 8-Mar-11 20:50pm    
----------------------------------------------
(Sorry, the above comment is kept as true, it is just deleted without care.)
Sergey Alexandrovich Kryukov 8-Mar-11 20:57pm    
OK, thank you for accepting my Answer.
Good luck,
--SA
Sports Kuo 16-Mar-11 1:39am    
============================================================
Thanks of your prompt response of my question.
I've clicked the line on your name to enter into your profile in CodeProject, however I can't find out any 'contact me' page ! Any step I miss to reach it ? Could you provide detailed steps for it ? Thanks.

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