Question

i must create a "searchable" property grid, that is a textbox placed on the top followed by property grid. Rather then using a user control i would extend property grid directly, but i' m not able to add a child textbox control on the fly. Anyone can help me? Thank you a lot!

Was it helpful?

Solution

The PropertyGrid internal control creation flow is undocumented. It's composed by a ToolStrip, a internal grid, the description pane and the action pane.

I tried to add a control to this existing collection : it causes issues in the whole control layout which seems to be done by some internal custom calculations, rather than the existing well-known NET layout mechanism.

It could probably be enforced by using Reflection, but I dont even have tried it because it would be hard on one hand, and on the other it would compromise the ascending compatability of future releases of the PropertyGrid.

I ended up using a UserControl where I put a top-docked TextBox, with a fill-docked PropertyGrid, and added this property :

public PropertyGrid InnerPropertyGrid
{
    get
    {
        return this.propertyGrid1;
    }
}

By this way, all my PropertyGrid properties, methods and events are exposed, even during design mode.

It is not the smartest way to do, but it's quicker and easier than trying to hack some private parts of this control.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top