By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,844 Members | 1,889 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,844 IT Pros & Developers. It's quick & easy.

How to put a clickable button on a PropertyGrid ?

P: n/a
I'm using the PropertyGrid control, and I want it to show a button.
But I set the PropertyGrid.SelectedObject with a object that as a Button
property, the PropertyGrid shows the buttons properties, and I want the
button to be shown as drawn and clickable button.

How can I do that?

--
Thanks
Sharon
Sep 20 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
IIRC, you can just do grid.Controls.Add(); [and be sure to bring your
control to the front afterwards]

Note that PropertyGrid.Controls doesn't show in the list, but it works just
fine. A better approach, however, may be to add a "tab"; these (bizarrely)
display as buttons; they are implemented differently, but give you more
control - simply inherit from PropertyTab and implement the necessary
methods (such as GetProperties if you want to filter the list).

Just type "PropertyTab Class" into MSDN2 (making sure you get
System.Windows.Forms.Design in 2.0) and you get a nice example. Note also
that the first tab seems to be always hidden, so you may need to add another
clone of PropertiesTab if you want to be able to swith back ;-p [just
subclass PropertiesTab and don't change anything (maybe the image) to
achieve this]

Marc
Sep 20 '06 #2

P: n/a
Thanks a lot for your help.
But I'm afraid that I did not explain my self as I should have.

When I implemented your suggestion, I got a button on the PropertyGrid frame
part on top, but I need the button to be shown on one of the cells at the
right column of the PropertyGrid.
I need the button to be shown instead of the value cell. The user should see
a clickable button that he'll be able to click on to perform some kind of
operation.

There may be some more buttons to be shown on another PropertyGrid cells.

Can you help me with that?
--------
Thanks
Sharon
Sep 20 '06 #3

P: n/a
Oh, that!

You need to implement a UITypeEditor, which can provide either a popup or a
drop-down (both drawing whatever you want). If fixed drop-down (text) lists
and text editing / parsing are what you want, then you also need to look at
TypeConverter.

See MSDN: http://msdn2.microsoft.com/en-us/library/ms171840.aspx

(note that although you can support painting a preview in the grid, you
can't really put a button there until the user selects the drop-down; think
of the Dock /Anchor propertes for forms and you'll get the picture).

Note that this aspect of the component model can take some time to
understand, but it is very powerful.

Marc
Sep 20 '06 #4

P: n/a
Note the example I cited uses the drop-down approach; actually, the pop-up
(form) approach can be easier... google will be your friend here... you are
looking for UITypeEditorEditStyle.Modal - perhaps:
http://www.awprofessional.com/articl...&seqNum=5&rl=1

Note also that there are base-classes like the collections-editor that you
can extend through inheritance.

Marc
Sep 20 '06 #5

P: n/a
Hello Sharon,

with the Microsoft PropertyGrid, there will be no way to have a button
that fills all the value cell space. If you want to look into
commercial product, this is something that Smart PropertyGrid.Net can
do by creating a custom inplace control. You can have a look at
http://www.visualhint.com

Best regards,

Nicolas Cadilhac
VisualHint - Home of Smart PropertyGrid.Net

Sharon wrote:
Thanks a lot for your help.
But I'm afraid that I did not explain my self as I should have.

When I implemented your suggestion, I got a button on the PropertyGrid frame
part on top, but I need the button to be shown on one of the cells at the
right column of the PropertyGrid.
I need the button to be shown instead of the value cell. The user should see
a clickable button that he'll be able to click on to perform some kind of
operation.

There may be some more buttons to be shown on another PropertyGrid cells.

Can you help me with that?
--------
Thanks
Sharon
Sep 21 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.