all groups > dotnet windows forms designtime > april 2005 >
You're in the

dotnet windows forms designtime

group:

How to replace the GridSize designtime property on a Custom Control with my own


How to replace the GridSize designtime property on a Custom Control with my own Robin Sanner
4/9/2005 10:22:27 AM
dotnet windows forms designtime:
I have a new custom control. By default the custom control has the
design-time property GridSize. I want my custom control to have it's own
GridSize property that works in both design time and in run time and be
browsable in design-time. I used PostFilterProperties to get rid of the
original GridSize property but how do I retrieve the property descriptor for
the GridSize property on my control? If I try to use
TypeDescriptor.GetProperties(mycontrol)("GridSize") it causes
PostFilterProperties to run again and creates a stack overflow situation.

Thank you
Robin Sanner
robin.sanner@verizon.net

Re: How to replace the GridSize designtime property on a Custom Control with my own Mujdat Dinc
4/22/2005 2:59:53 PM
Hi Robin..
Try this..
// Your designers override code
protected override void PreFilterProperties(System.Collections.IDictionary
properties)
{
base.PreFilterProperties (properties);
PropertyDescriptor pd = properties["GridSize"] as PropertyDescriptor ;
if(pd != null && pd.DesignTimeOnly )
properties.Remove("GridSize");
}

Mujdat

[quoted text, click to view]

Re: How to replace the GridSize designtime property on a Custom Control with my own Robin Sanner
4/26/2005 2:07:44 PM
That gets rid of the design time GridSize property but I still can't see the
GridSize property that is on my control.

[quoted text, click to view]

Re: How to replace the GridSize designtime property on a Custom Control with my own Mujdat Dinc
4/28/2005 12:00:00 AM
Robin,
Yes you are right .It s happenning because of the base object Prefilter
call overwrites original Properities..
If you save the original, call base , remove design time and restore
original ,it will work.
The second approch is more complex. It is implementing CustomProperty
descriptor..

protected override void PreFilterProperties(System.Collections.IDictionary
properties)
{
//Save objects runtime property before base call overrite it
PropertyDescriptor pdObject = properties["GridSize"] as
PropertyDescriptor ;
// Fill design time properties
base.PreFilterProperties (properties);

//Restore runtime property
properties["GridSize"] = pdObject;

}

[quoted text, click to view]

AddThis Social Bookmark Button