473,508 Members | 3,343 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Attaching an editor to a property at runtime

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.


Nov 16 '05 #1
2 3021
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" <am**********@prodigy.net.mx> wrote in message
news:Oy**************@TK2MSFTNGP10.phx.gbl...
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.

Nov 16 '05 #2
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" <al*******@omnitalented.com> escribió en el mensaje
news:%2******************@TK2MSFTNGP09.phx.gbl... 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" <am**********@prodigy.net.mx> wrote in message
news:Oy**************@TK2MSFTNGP10.phx.gbl...
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.


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2353
by: m. pollack. | last post by:
Hi all, Is there any information to be had about the "Object Collection Editor" that appears when you click on a collection property in the PropertyGrid control? I have a class that maintains a...
0
1843
by: Dave | last post by:
Hi everyone, (I already posted this to the VS.NET IDE news group without any responses, so I'm attempting one more time in this group) The issue I'm having is occuring in the IDE of VS.NET...
1
4704
by: Mark Kamoski | last post by:
Hi-- All of sudden (?) the VS.NET v1 IDE is NOT automatically attaching aspnet_wp.exe as a debugged process. Why? Here is the situation. VS.NET (v1)
3
4304
by: Shimon Sim | last post by:
I have control. One of the properties is implemented as StringCollection. I didn't use any Editor attribute for it. During Design time system shows dialog similar to Items in DropDownList but Add...
4
2492
by: Michael | last post by:
Dear all .. If I want to use develop a user control and declare a public property which the type is System.Windows.Forms.GridTableStylesCollection For example : Public Class LookAndView...
0
1276
by: Olivier Ishacian | last post by:
XMLmind XML Editor V3.0 Patch 1 can be downloaded from http://www.xmlmind.com/xmleditor/download.shtml _____________________________________________ V3.0 Patch 1 (December 2, 2005) ...
0
882
by: john | last post by:
Hi, I have a simple VB .NET application using SQL Express and datasets. The connection string for my datasets is pointing to my development location. At runtime I change the connection string...
2
2303
by: ARC | last post by:
(sorry for the re-post, but I thought I would put the winmail.dat where it's visible in the subject...thanks!) Hello all, I have a question that I hope someone can help with. I have an Access...
2
4210
by: R.A.F. | last post by:
Hi, I have a custom control in which i have a collection property named "Columns". this collection property add/remove column objects. in my Column class i have a property named Alignment...
0
7129
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7398
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7061
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5637
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3208
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3194
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.