> There are several articles at CodeProject covering
> ICustomTypeDescriptor [1]

        Be aware that ICustomTypeDescriptor causes problems in .NET 2.0 
databinding, especially with property discovery for design
time databinding and for example all the ASP.NET 2.0 datasourcecontrols ignore 
properties from ICustomTypeDescriptor implementing
objects. I.o.w.: if you're on .NET 2.0, don't use ICustomTypeDescriptor.

        MS is aware of the problem, see for more info here:

http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=8e892ec2-cfec-4a0d-b0c7-4f6d38910726

        though as you can see, they're not going to 'fix' this in the current 
release.

                Frans

>
> Regards,
> Thomas
>
> [1]
> http://www.google.com/search?q=ICustomTypeDescriptor%20site:co
> deproject.com
>
> On 3/14/06, Charles Gamble <[EMAIL PROTECTED]> wrote:
> > That sounds perfect.
> > Any example implementations that I could base my code on?
> >
> > Thanks,
> >         Charles.
> >
> > -----Original Message-----
> > From: Discussion of advanced .NET topics.
> > [mailto:[EMAIL PROTECTED] On Behalf Of Ian
> > Griffiths
> > Sent: 14 March 2006 12:46
> > To: [email protected]
> > Subject: Re: [ADVANCED-DOTNET] Changing attributes at runtime
> >
> > It's not possible to do it the way you're trying to, but there's an
> > alternative solution that should give you the result you require.
> >
> > If you want to change categories at runtime, you need to
> look at the
> > ICustomTypeDescriptor interface.
> >
> > This lets you advertise a dynamic set of properties. The
> PropertyGrid
> > will use this instead of using your real properties if you
> implement
> > this interface.
> >
> > You can use this to change the attributes the PropertyGrid sees
> > dynamically.
> >
> > It may seem like overkill - it lets you make *everything*
> dynamic. But
> > it's easy enough to defer to the TypeDescriptor and
> PropertyDescriptor
> > classes to do the majority of the work, and just tweak the results
> > before returning them.
> >
> > (This probably won't let you change category when you're already in
> > the grid. I suspect it only looks for the category at the point at
> > which the object is set as the SelectedObject.)
> >
> >
> > --
> > Ian Griffiths
> >
> > -----Original Message-----
> > From: Charles Gamble
> >
> > Is it possible to change attributes at runtime? (I am using C#)
> >
> > The reason I want to do this is because I am using
> > System.ComponentModel to define attributes with my class
> properties to
> > be used in a System.Windows.Forms PropertyGrid.
> >
> > However I would like to be able to change the Category
> attribute for
> > individual properties at runtime?
> >
> >
> >
> > I have used to following code to get at the Category attribute, but
> > everything seems to be read only:
> >
> > Type myType = myObject.GetType();
> >
> > PropertyInfo Name = myType.GetProperty("Name");
> >
> > CategoryAttribute categoryAttr = Attribute.GetCustomAttribute(Name,
> >
> >                   typeof(CategoryAttribute));
> >
> >
> >
> > Is this possible? If not how else could I do it?
> >
> > ===================================
> > This list is hosted by DevelopMentor(r)  http://www.develop.com
> >
> > View archives and manage your subscription(s) at
> > http://discuss.develop.com
> >
> >
> ______________________________________________________________________
> > __ This e-mail has been scanned for all viruses by MessageLabs.
> >
> ______________________________________________________________________
> > __
> >
> >
> ______________________________________________________________________
> > __ This e-mail has been scanned for all viruses by MessageLabs.
> >
> ______________________________________________________________________
> > __
> >
> > ===================================
> > This list is hosted by DevelopMentor(r)  http://www.develop.com
> >
> > View archives and manage your subscription(s) at
> > http://discuss.develop.com
> >
>
> ===================================
> This list is hosted by DevelopMentorR  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>
>

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to