... edit #2 ...
CodeProject has many articles involving modifying the PropertyGrid: [
^]
... end edit #2 ...
... edit #1 ...
In addition to the CP article linked to in Espen's comment above, you may find value in the CP article: "Making a PropertyGrid ReadOnly," by Rajeev511, 2010: [
^]. Using the techniques in that article, it's not clear, to me, if you can make
specific properties in the PropertyGrid readonly, and I have posted a question about that in the article's comments' section.
... end edit #1 ...
While I will share here some ideas, and code, that will kind of get you started on restricting which elements appear in a PropertyGrid, if you are only wanting to allow the end-user to edit just three Properties ('Location, 'Size, 'Text), I think you might consider just writing your own simple pop-up UserControl.
However, it is "cool" to see some visual aspect of a Control change when you change the value in a PropertyGrid, and hit return !
However, that could be simulated in a pop-up UserControl, also. mmmm ... maybe I should write a Tip/Trick on doing that ? :)
My comments are based on this 2006 CodeProject article, "Filtering properties in a PropertyGrid," by "bsargos" [
^].
There is a fairly easy way to restrict what is shown in a PropertyGrid by certain CategoryAttributes, like "Layout," "Appearance," etc. You can find a current list (for .NET 4.0) of those attributes here [
^].
But, restricting what is shown to "Layout," for example, while it will expose Location, and Size, Properties: will
also expose many other Properties that you probably want to hide.
Here's some working code I wrote recently based on the CP article cited, that demonstrates using a CategoryAttribute restriction:
using System.ComponentModel;
private Attribute fltrAttributeLayout = new CategoryAttribute("Layout");
private AttributeCollection attribCollection;
private void Form1_Load(object sender, EventArgs e)
{
attribCollection = new AttributeCollection(new Attribute[]{fltrAttributeLayout});
propertyGrid1.BrowsableAttributes = attribCollection;
}
private void ShowPropertyGrid_Click(object sender, EventArgs e)
{
propertyGrid1.SelectedObject = sender;
propertyGrid1.Focus();
}
I hope these remarks, and this code, will be helpful to get you started. I have just begun to look into the more complex method of "fine-grained" editing which PropertyGrid elements appear, described in that 2006 CP article, and I'm researching the topic actively on both CP, and StackOverFlow. Would be good to find a simpler method. If I find one, I'll post it here.
Hope someone comes along with a full answer :)