Click here to Skip to main content
11,483,983 members (66,149 online)
Rate this: bad
Please Sign up or sign in to vote.
i'm making my own user control and have 2 questions
1. i want to add a button on default properties list and i want to open a modal form when that button is clicked,
2. i want to group my control properties in one category (the attribute Category(...) doesn't work, as i found it works only with property grid added by me)
Posted 26-Feb-11 13:01pm
Edited 26-Feb-11 13:21pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

This is quite possible but not easy at all; you'll to write several things to allow custom edit in the PropertyGrid. I think modal form is not a good idea as you can do much better by providing a custom in-place editor. However, a modal form is also possible: you in-line editor will be the button you want; and this button will show your modal form.

I tried to describe a road map on this topic here: How to get response when click PropertyGrid[^].

Again, this is not easy, so I'm sorry I cannot afford developing code specially for your case. It would be far beyond the format of CodeProject Questions-and-Answers. You can get the idea, go to help pages on the types I list in my Answer and write your own code, ask another question if and when you face any problems.

See also: Setting value in textbox when it is taken from combobox..[^].

Good luck,
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

To achieve your aims you will probably have to write a UITypeEditor[^] and one or more ControlDesigners or one of its descendants and quite possibly one or more TypeConverters. From your description possibly an ExpandableObjectConverter[^].

Here is a link to an example that uses most of these.[^]
SAKryukov at 27-Feb-11 12:38pm
Henry, just to note: this is more complex then you're trying to explain here. Pointing to UITypeEditor points in right direction, only one step in many. Basic idea is that you never need to change property grid, you need to create special data class to be shown in the grid to wrap around "real" data; such "fake" data should be designed the way to use one or another UITypeEditor; as to ExpandableObjectConverter, I'm pretty much sure, there is not need in it in this situation.
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

I thought something about this
<pre lang="cs">public Sometype PropertyName
      return SomeValue;
     (new Form()).ShowDialog();

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 210
1 Frankie-C 165
2 Raje_ 155
3 OriginalGriff 142
4 Abhipal Singh 108
0 Sergey Alexandrovich Kryukov 8,489
1 OriginalGriff 7,943
2 Sascha Lefèvre 3,114
3 Maciej Los 2,581
4 Richard Deeming 2,370

Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 27 Feb 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100