473,503 Members | 5,284 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PropertyGrid: CategoryAttribute + BrowsableAttributes

Hi All,

I have a form containing only a PropertyGrid that I use to modify an
instance of the following class:

class MyClass
{
Point _point = new Point();

[CategoryAttribute("Drawing")]
public Point MyPoint
{
get { return _point; }
set { _point = value; }
}
}

All works fine.

Now if I add

this._propertyGrid.BrowsableAttributes
= new AttributeCollection(
new Attribute[] { new CategoryAttribute("Drawing") });

to the form's initialization code: what happens is that "MyPoint"
property does not more expand in the PropertyGrid.

Is there a way to apply the CategoryAttribute only to the first level of
properties?

TIA.
Marco.
Oct 12 '07 #1
2 7925
Hello Marco,

I guess that you are trying to show only properties (and their
subproperties) that are under a particular category. Unfortunately you
are not using the right tool to do that. Your subproperties get
filtered because they don't have the CategoryAttribute you supply. A
better way would be to use a TypeDescriptor or TypeConverter for your
class that would filter out any toplevel property that is not under
the category (it would publish only the PropertyDescriptors that have
the CategoryAttribute).

Best regards,

Nicolas Cadilhac @ VisualHint (http://www.visualhint.com)
Home of Smart FieldPackEditor.Net / DateTimePicker replacement (http://
www.visualhint.com/index.php/fieldpackeditor)
Home of Smart PropertyGrid for .Net and MFC (http://www.visualhint.com/
index.php/propertygrid)
Microsoft PropertyGrid Resource List - http://www.propertygridresourcelist.com
On Oct 12, 8:45 am, Marco Segurini <marcosegur...@gmail.comwrote:
Hi All,

I have a form containing only a PropertyGrid that I use to modify an
instance of the following class:

class MyClass
{
Point _point = new Point();

[CategoryAttribute("Drawing")]
public Point MyPoint
{
get { return _point; }
set { _point = value; }
}
}

All works fine.

Now if I add

this._propertyGrid.BrowsableAttributes
= new AttributeCollection(
new Attribute[] { new CategoryAttribute("Drawing") });

to the form's initialization code: what happens is that "MyPoint"
property does not more expand in the PropertyGrid.

Is there a way to apply the CategoryAttribute only to the first level of
properties?

TIA.
Marco.

Oct 12 '07 #2
Marco,

Unfortunately, no. You would have to apply the appropriate attributes
to your parent class (which I can see you not wanting to do, for obvious
reasons).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Marco Segurini" <ma***********@gmail.comwrote in message
news:fe**********@aioe.org...
Hi All,

I have a form containing only a PropertyGrid that I use to modify an
instance of the following class:

class MyClass
{
Point _point = new Point();

[CategoryAttribute("Drawing")]
public Point MyPoint
{
get { return _point; }
set { _point = value; }
}
}

All works fine.

Now if I add

this._propertyGrid.BrowsableAttributes
= new AttributeCollection(
new Attribute[] { new CategoryAttribute("Drawing") });

to the form's initialization code: what happens is that "MyPoint" property
does not more expand in the PropertyGrid.

Is there a way to apply the CategoryAttribute only to the first level of
properties?

TIA.
Marco.

Oct 12 '07 #3

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

Similar topics

3
7302
by: Nicolas | last post by:
I want to display in my application a PropertyGrid showing only the "Appearance" of a control (ie. textBox) so the user can change it. Bare with me, I'm new in csharp. Where do I go from:...
2
3955
by: Mevar81 | last post by:
Hi to everybody.I have a problem with the PropertyGrid control.I want to display not all the properties of a generic Control(Button,TextBox,ComboBox,ecc.).In general I don't want to display only...
1
24625
by: Daniel | last post by:
How do I use a combobox in a propertygrid without using enum ? Any suggestions?
4
3063
by: Bernie Yaeger | last post by:
How can I set the browsableattributes of the control that has been selected (selectedobject) by the propertygrid? Here's what I'm after - I want to open a form with a propertygrid in it. The...
0
1327
by: tg.foobar | last post by:
i'm using a propertygrid to show / edit values of a class that i have. I'm using the new(er) nullable types and it's showing the value of these items as empty (as i would think), but the...
0
850
by: Massimo | last post by:
I'm creating a class for propertygrid, but I have a question about CaregoryAttribute, DisplayName and DescriptionAttribute: CategoryAttribute("Language") DisplayName("Language") ...
2
2338
by: =?Utf-8?B?Sm9obiBPbGJlcnQ=?= | last post by:
I am trying to set the PropertyGrid. BrowsableAttributes to multiple values of CategoryAttribute but if I use more then one no properties are displayed. Code below-- Attribute filterattribute1=new...
3
5112
by: michelqa | last post by:
Hi, I have a form with a control..(a button for example). Then the control properties are displayed in a propertyGrid control. Is there any simple way to remove some unwanted properties from...
0
1198
by: sandeepkavade | last post by:
Hi, I am basically a VC++ developer but now working on C#. I am having a assembly in that i have added a UserControl and on that UserControl I am having a tree-view control and Property Grid...
0
7070
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...
1
6976
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
7449
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
5566
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
4666
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
3160
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
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
729
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
372
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.