I have an app that allows the user to choose an image, at design time, either as a straight image, or from an image list.
All cool so far, except that this is not happening from the visual studio property browser, its happening from a property grid that is a part of a type editor.
My problem is, both the image picker (actually resource picker), and the imagelist type converter rely on some design-time services to get the job done. In the case of imagelist, its the IReferenceService and in the case of the resource picker its a service called _DTE.
In the first instance of an edit from the visual studio property browser, I could get a reference to these services but (1) how can I add them to the type descriptor context of my property grid?
It would be better, for future proofing, if I could just copy a reference to all of the services in the type descriptor context. (2) Where does the property browser get these services from in the first place?
ETA: I still don't know how to do it, but I now know it is possible.
(1) Sub-class control and add a property whose type is an array of buttons.
(2) Add it to a form.
(3) Select the new control on the design service and edit the new property in the property browser.
(4) The collection editor dialog pops-up
(5) Add a button
(6) Edit image and image list - the type editor and type converter, respectively, behave as they should.
ETA2: Ok, I'm getting warm. It looks like you do it through the Site property of the property grid. I can create a new site, and pass it the type descriptor context I have a reference to and then it should have all the service. I'll give it a go ...
ETA3: Yes, that's it. I'll add an answer.