PC Review


Reply
Thread Tools Rate Thread

Attaching an editor to a property at runtime

 
 
Luis Arvayo
Guest
Posts: n/a
 
      21st Mar 2005
Is there some way to attach an editor to a property of a class at runtime ?

Ex.;


public class MyClass
{

[Editor(typeof(ImageEditor),typeof(UITypeEditor)]
public int BitmapIndex
{
get {...}
set {...}
}
}

Instead of defining statically before compile time, I need to define the
editor at runtime in order to be used together with the PropertyGrid. Is tha
possible ?

Thanks
Luis A.




 
Reply With Quote
 
 
 
 
Alexander Shirshov
Guest
Posts: n/a
 
      22nd Mar 2005
Luis,

My guess is you need to use ICustomTypeDescriptor together with your own
class that inherit from PropertyDescriptor. PropertyDescriptor's protected
constructor allows you to pass an array of attributes for this property.
This thread might get you started:
http://discuss.develop.com/archives/...S&P=R4310&I=-3

Out of curiosity, why can't you apply attributes at compile time?

HTH,
Alexander

"Luis Arvayo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Is there some way to attach an editor to a property of a class at runtime
> ?
>
> Ex.;
>
>
> public class MyClass
> {
>
> [Editor(typeof(ImageEditor),typeof(UITypeEditor)]
> public int BitmapIndex
> {
> get {...}
> set {...}
> }
> }
>
> Instead of defining statically before compile time, I need to define the
> editor at runtime in order to be used together with the PropertyGrid. Is
> tha possible ?
>
> Thanks
> Luis A.
>
>
>
>



 
Reply With Quote
 
Luis Arvayo
Guest
Posts: n/a
 
      22nd Mar 2005
Hi,

Thanks for the response and tips.

> Out of curiosity, why can't you apply attributes at compile time?


This is a class which the developer (this is a tool for developers) could
want to add its own property editor in order to use together with
PropertyGrid, and I don't want to define a fixed editor. That is to say, the
point here is the customization of the editor, instead of a fixed one.

I know that in order to use the PropertyGrid with custom editors, an wrapper
could be used for this class but that will be much more work.

Thanks
Luis A.


"Alexander Shirshov" <(E-Mail Removed)> escribió en el mensaje
news:%23%(E-Mail Removed)...
> Luis,
>
> My guess is you need to use ICustomTypeDescriptor together with your own
> class that inherit from PropertyDescriptor. PropertyDescriptor's protected
> constructor allows you to pass an array of attributes for this property.
> This thread might get you started:
> http://discuss.develop.com/archives/...S&P=R4310&I=-3
>
> Out of curiosity, why can't you apply attributes at compile time?
>
> HTH,
> Alexander
>
> "Luis Arvayo" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Is there some way to attach an editor to a property of a class at runtime
>> ?
>>
>> Ex.;
>>
>>
>> public class MyClass
>> {
>>
>> [Editor(typeof(ImageEditor),typeof(UITypeEditor)]
>> public int BitmapIndex
>> {
>> get {...}
>> set {...}
>> }
>> }
>>
>> Instead of defining statically before compile time, I need to define the
>> editor at runtime in order to be used together with the PropertyGrid. Is
>> tha possible ?
>>
>> Thanks
>> Luis A.
>>
>>
>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How could I change the NavigateUrl property at runtime based on another controls property ? Radu Microsoft ASP .NET 2 25th Jan 2007 10:51 AM
UserControl with a Decimal Property with a DefaultValue is not handled correctly by Property Editor Shadow Lynx Microsoft VB .NET 0 12th Apr 2006 02:18 AM
Runtime Error 380 – Could not set the list property. Invalid property value BernzG Microsoft Excel Programming 0 19th Aug 2005 05:22 AM
PropertyGrid - attaching UITypeEditor without using Editor attribute? Dr. Proctor Microsoft Dot NET Framework Forms 1 30th May 2005 10:52 AM
Runtime error 380: Could not set the List property. invalid property value of listbox jasgrand Microsoft Excel Programming 0 6th Oct 2004 09:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:54 PM.