Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / April 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robin Sanner - 09 Apr 2005 18:22 GMT
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
Mujdat Dinc - 22 Apr 2005 12:59 GMT
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

>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
[quoted text clipped - 8 lines]
> Robin Sanner
> robin.sanner@verizon.net
Robin Sanner - 26 Apr 2005 22:07 GMT
That gets rid of the design time GridSize property but I still can't see the
GridSize property that is on my control.

> Hi Robin..
> Try this..
[quoted text clipped - 23 lines]
>> Robin Sanner
>> robin.sanner@verizon.net
Mujdat Dinc - 28 Apr 2005 15:36 GMT
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;

 }

> 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 clipped - 25 lines]
>>> Robin Sanner
>>> robin.sanner@verizon.net

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.