473,320 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Applying Attributes of an instance of an object to its member prop

I have a complex object created and filled with data for display in a
property Grid. In many cases I need the data to be ranged, formatted and a
'units' string to be appended. To this end, I created an my own attribute
type where these things can be attached to a property and later used by a
custom converter.

This works well on most of my items. However...

In my particular application there are many items that have 'Port' value and
a 'STbd' value. I created a data type consisting of 2 items. (The item
Types vary in my app so I made this a generic type... )

This all works well and good for the most part; the problem comes when I
want to format and range the PORT/STBD items contained in the instance.

I would like to decorate the instance with the attribute for
range/format/units and somehow have that attribute information drill down and
apply to the member items.

I have tried many approaches to no avail...

I tried to decorate the member item of the PORT/STBD type with a
UsesParentObjectsAttributesAttribute so during the GetProperties call to my
customTypeDescriptor I could use the GetPropertyOwner() call and access its
attributes... This looked promising but it seemed I could only access the
parent's Type attributes and not those of the instance.

Another thing I thought looked promising was using the
attributeProviderAttribute to redirect the Port/Stbd items to use a different
attribute. Again I think you can only redirect to the attributes of a type
and not an instance.

Is what I'm trying even possible? If so how?
Jul 24 '07 #1
0 920

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

Similar topics

50
by: Dan Perl | last post by:
There is something with initializing mutable class attributes that I am struggling with. I'll use an example to explain: class Father: attr1=None # this is OK attr2= # this is wrong...
4
by: Paul | last post by:
Hi! I have a problem: I've declared some classes and decorated them with my Custom Attributes. (say ClassA and ClassB) Now I have some Type member (in fact this is FieldInfo.FieldType) which is...
2
by: S.Sigal | last post by:
Hello: I've seen code in some books for databinding that handles attaching Attributes to Properties during runtime...which is very close (but no cigar) to what I am looking for... The code...
5
by: zkvneml | last post by:
Hi guys, Is there a way to retreave the javascript functions' names on the page? The javascript functions are properties of the global object (window/frame), but I do not know how to collect...
6
by: Samuel M. Smith | last post by:
I have been playing around with a subclass of dict wrt a recipe for setting dict items using attribute syntax. The dict class has some read only attributes that generate an exception if I try to...
2
by: Mythran | last post by:
System.Drawing.SystemColors is a class with all static properties. Here is what my short-ranged goal is... I want to enumerate all of the SystemColors properties and print the name (using...
3
by: redefined.horizons | last post by:
I've been reading about Python Classes, and I'm a little confused about how Python stores the state of an object. I was hoping for some help. I realize that you can't create an empty place holder...
5
by: Kimmo Laine | last post by:
Hi is there a way to change propertys attribute from the code? Let´s say that i have the following property in my class: public int Count } Is there a way to change the displayname, from...
10
by: Joe Kovac | last post by:
Hi! I have a class with many bool attributes. Now I want to set them all at once to true or false, without forgetting one or the other. Any easy way to do that? (e.g. using reflection) ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.