Adding attributes to properties or fields at design time.

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I have a component that does some interesting stuff exposing the member properties of a child control within a usercontrol properties of the parent control using a TypeDescriptionProvider.

Effectively, instead of dropping a text box on a control and then writing a property to expose the textbox's Text property, you just declare an attribute saying "expose the Text property of textBox1 in a property called MyText"

At the moment I have to physically write an attribute for each of the properties I want to expose but I'd really like to do something in the style of an ExtenderProvider and be able to have the design time add the attributes to the class declaration and serialize the whole lot automatically.

If you have any idea of how I might accomplish that I'd be happy to hear from you.

Please feel free to send me code to my personal address which can be obtained by removing the spamkiller from my e-mail address.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


.



Relevant Pages

  • Re: Zoom effect on winforms
    ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Answer those GDI+ questions with the GDI+ FAQ ... I have a custom control which i want it to draw ina rectangle a picture ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Raise an event?
    ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Answer those GDI+ questions with the GDI+ FAQ ... > control that contains a button. ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Font size based on the client rectangle of the control.
    ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Answer those GDI+ questions with the GDI+ FAQ ... I have a control that render text. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Create a Bitmap of a webpage programmatically...how?
    ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Answer those GDI+ questions with the GDI+ FAQ ... > control, without opening any forms. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Complex Shapes Over other Windows (I can see it being done!)
    ... I have had limited success with objects based on Control because they carry ... NativeWindow and the LayeredWindow API. ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Answer those GDI+ questions with the GDI+ FAQ ...
    (microsoft.public.dotnet.framework.drawing)