469,272 Members | 1,569 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,272 developers. It's quick & easy.

Property's Description and Category do not work


All,

I created a control that have the following property defined:

private bool autoSearch
[
DefaultValue(typeof(bool),true),
Description("Auto search upon typing"),
Category("Behavior")
]
My control is compiled and created fine. But, after adding the control to
my form, I noticed the following problems:

1. The autoSearch property does not show up in the Behavior category.
Instead, it's shown in the Misc. category.
2. The Decription does not show up at all. I can see the autoSearch
property. I can change its value from true to false. But when I clicked on
the autoSearch, its desciption does not show up.

Can someone shed a light on this?

Thanks.
Nov 15 '05 #1
5 5933
100
Hi David,
You should specify attributes before the names they apply to:
[ DefaultValue(typeof(bool),true),
Description("Auto search upon typing"),
Category("Behavior")]
private bool autoSearch

HTH
B\rgds
100


" David N" <dq*****@netiq.com> wrote in message
news:uq**************@tk2msftngp13.phx.gbl...

All,

I created a control that have the following property defined:

private bool autoSearch
[
DefaultValue(typeof(bool),true),
Description("Auto search upon typing"),
Category("Behavior")
]
My control is compiled and created fine. But, after adding the control to
my form, I noticed the following problems:

1. The autoSearch property does not show up in the Behavior category.
Instead, it's shown in the Misc. category.
2. The Decription does not show up at all. I can see the autoSearch
property. I can change its value from true to false. But when I clicked on the autoSearch, its desciption does not show up.

Can someone shed a light on this?

Thanks.

Nov 15 '05 #2

"100" <10*@100.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Hi David,
You should specify attributes before the names they apply to:
[ DefaultValue(typeof(bool),true),
Description("Auto search upon typing"),
Category("Behavior")]
private bool autoSearch

HTH
B\rgds
100


" David N" <dq*****@netiq.com> wrote in message
news:uq**************@tk2msftngp13.phx.gbl...

All,

I created a control that have the following property defined:

private bool autoSearch
[
DefaultValue(typeof(bool),true),
Description("Auto search upon typing"),
Category("Behavior")
]
My control is compiled and created fine. But, after adding the control to my form, I noticed the following problems:

1. The autoSearch property does not show up in the Behavior category.
Instead, it's shown in the Misc. category.
2. The Decription does not show up at all. I can see the autoSearch
property. I can change its value from true to false. But when I
clicked on
the autoSearch, its desciption does not show up.

Can someone shed a light on this?

Thanks.


Nov 15 '05 #3
Sorry for all blank replies. My machine was out of memory and when I press
enter key, some how the message dialog was closed and the message was
sent....

Anh thank you for your reply. I swapped the attributes on top of the
property, but the result is the same. Beside, I don't think the position
makes the different, because I have another property of type string, and the
default value of each property was shown correctly...

"100" <10*@100.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Hi David,
You should specify attributes before the names they apply to:
[ DefaultValue(typeof(bool),true),
Description("Auto search upon typing"),
Category("Behavior")]
private bool autoSearch

HTH
B\rgds
100


" David N" <dq*****@netiq.com> wrote in message
news:uq**************@tk2msftngp13.phx.gbl...

All,

I created a control that have the following property defined:

private bool autoSearch
[
DefaultValue(typeof(bool),true),
Description("Auto search upon typing"),
Category("Behavior")
]
My control is compiled and created fine. But, after adding the control to my form, I noticed the following problems:

1. The autoSearch property does not show up in the Behavior category.
Instead, it's shown in the Misc. category.
2. The Decription does not show up at all. I can see the autoSearch
property. I can change its value from true to false. But when I
clicked on
the autoSearch, its desciption does not show up.

Can someone shed a light on this?

Thanks.


Nov 15 '05 #4
My fault!
The attribute declaration does have to be before the property {get/set}
pair. I have to close the solution and reopen it in order to see the
change.

Thanks a lot.

" David N" <dq*****@netiq.com> wrote in message
news:uq**************@tk2msftngp13.phx.gbl...

All,

I created a control that have the following property defined:

private bool autoSearch
[
DefaultValue(typeof(bool),true),
Description("Auto search upon typing"),
Category("Behavior")
]
My control is compiled and created fine. But, after adding the control to
my form, I noticed the following problems:

1. The autoSearch property does not show up in the Behavior category.
Instead, it's shown in the Misc. category.
2. The Decription does not show up at all. I can see the autoSearch
property. I can change its value from true to false. But when I clicked on the autoSearch, its desciption does not show up.

Can someone shed a light on this?

Thanks.

Nov 15 '05 #5
100
Hi David,
I'm glad that you managed to solve your problem. I just want to point you on
the fact that the position of the attribute declaration *does* matter.
Attributes are applied on the declaration that follows the place where the
attribute is specified. If there is ambiguity or your intent is different
than what is the default target an "atribute target specifier" can be used.

So in your example
private bool autoSearch
[
DefaultValue(typeof(bool),true),
Description("Auto search upon typing"),
Category("Behavior")
]

The attributes will be applied to what follows.

And if your code looks like this:

private bool autoSearch
[
DefaultValue(typeof(bool),true),
Description("Auto search upon typing"),
Category("Behavior")
]
public bool Foo()
{
......
}

The attribute is going to be applied to Foo method rather than autoSearch
member.

The attribute declaration does have to be before the property {get/set}
pair. I don't realy understand what *before {get/set} pair* means.
If you have:

bool Prop
[SomeAttribute]
{
get{}
set{}
}

It is a syntax error and this won't compile.
----------------------------------------
[SomeAttribute]
bool Prop
{
get{}
set{}
}

You apply the attribute to the property.
-----------------------------------------
bool Prop
{

[SomeAttribute]
get{}
set{}
}

I this case by default the attribute will be applied to the *get* method.
You can apply the attribute to the returning value using *return* target
specifier. Anyway, the property Prop itself won't have attribute applied.
-------------------------------------------
bool Prop
{
get{}

[SomeAttribute]
set{}
}
By default you apply the atribute to the *set* method. You can apply the
attribute to the *value* parameter via specifying *param* target. As in the
previous case the property itself won't have attribute applied.

So the position of the attributes *does* matter.

B\rgds
100
" David N" <dq*****@netiq.com> wrote in message
news:uq**************@tk2msftngp13.phx.gbl...

All,

I created a control that have the following property defined:

private bool autoSearch
[
DefaultValue(typeof(bool),true),
Description("Auto search upon typing"),
Category("Behavior")
]
My control is compiled and created fine. But, after adding the control to my form, I noticed the following problems:

1. The autoSearch property does not show up in the Behavior category.
Instead, it's shown in the Misc. category.
2. The Decription does not show up at all. I can see the autoSearch
property. I can change its value from true to false. But when I
clicked on
the autoSearch, its desciption does not show up.

Can someone shed a light on this?

Thanks.


Nov 15 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Steve Teeples | last post: by
2 posts views Thread by steve bull | last post: by
9 posts views Thread by Alphonse Giambrone | last post: by
7 posts views Thread by Andrea Moro | last post: by
2 posts views Thread by Rolf Welskes | last post: by
2 posts views Thread by Lespaul36 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.