Click here to Skip to main content
15,886,873 members
Home / Discussions / C#
   

C#

 
GeneralRe: How can I detect when a client disconnects from a well known service? Pin
LongRange.Shooter10-Feb-04 9:08
LongRange.Shooter10-Feb-04 9:08 
GeneralRe: How can I detect when a client disconnects from a well known service? Pin
Tom Larsen11-Feb-04 3:53
Tom Larsen11-Feb-04 3:53 
GeneralRe: How can I detect when a client disconnects from a well known service? Pin
HAHAHA_NEXT9-Feb-04 11:01
HAHAHA_NEXT9-Feb-04 11:01 
QuestionHow to get/set printer paper media type Pin
trythat9-Feb-04 5:55
trythat9-Feb-04 5:55 
QuestionDynamic attributes for propertyGrid??? Pin
LongRange.Shooter9-Feb-04 3:11
LongRange.Shooter9-Feb-04 3:11 
AnswerRe: Dynamic attributes for propertyGrid??? Pin
Heath Stewart9-Feb-04 4:17
protectorHeath Stewart9-Feb-04 4:17 
GeneralRe: Dynamic attributes for propertyGrid??? Pin
LongRange.Shooter9-Feb-04 8:09
LongRange.Shooter9-Feb-04 8:09 
GeneralRe: Dynamic attributes for propertyGrid??? Pin
Heath Stewart9-Feb-04 9:33
protectorHeath Stewart9-Feb-04 9:33 
You don't define the attribute, you extend the PropertyDescriptor class and override the ReadOnly property. What this property does to determine if true or false should be returned is up to your implementation. If you're setting the Thread.CurrentPrincipal to the current Windows principal (rather, the current WindowsIdentity with a WindowsPrincipal), you can use <code>IPrincipal.IsInRole (actually, you could do this without setting Thread.CurrentPrincipal, but this opens you up for role-based code access security as well). You could also attribute your properties subject to this condition with an attribute that dictates which roles are required.

The point is, in your ICustomTypeDescriptor.GetProperties implementation, you return a collection of your derived PropertyDescriptos that override the ReadOnly property.

For more information about ICustomTypeDescriptor, merely type it in your help index in VS.NET (if you installed the documentation, which is installed by default).

As far as all the methods, as I mentioned earlier you can provide the default implementation by using the appropriate TypeDescriptor method. I put that in my previous post. Each method declared by ICustomTypeDescriptor has a corresponding method defined by TypeDescriptor that takes a bool as (typically) the last parameter. Set this to true so that the implementation does NOT query your Type for the ICustomTypeDescriptor implementation (which would cause an infinite loop).

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: Dynamic attributes for propertyGrid??? Pin
LongRange.Shooter9-Feb-04 10:38
LongRange.Shooter9-Feb-04 10:38 
GeneralRe: Dynamic attributes for propertyGrid??? Pin
Heath Stewart9-Feb-04 14:02
protectorHeath Stewart9-Feb-04 14:02 
GeneralRe: Dynamic attributes for propertyGrid??? Pin
LongRange.Shooter10-Feb-04 8:58
LongRange.Shooter10-Feb-04 8:58 
GeneralRe: Dynamic attributes for propertyGrid??? Pin
Heath Stewart10-Feb-04 11:18
protectorHeath Stewart10-Feb-04 11:18 
GeneralRe: Dynamic attributes for propertyGrid??? Pin
LongRange.Shooter11-Feb-04 7:49
LongRange.Shooter11-Feb-04 7:49 
GeneralRe: Dynamic attributes for propertyGrid??? Pin
Heath Stewart11-Feb-04 9:14
protectorHeath Stewart11-Feb-04 9:14 
GeneralRe: Dynamic attributes for propertyGrid??? Pin
LongRange.Shooter11-Feb-04 10:45
LongRange.Shooter11-Feb-04 10:45 
GeneralRe: Dynamic attributes for propertyGrid??? Pin
Heath Stewart11-Feb-04 11:53
protectorHeath Stewart11-Feb-04 11:53 
GeneralCommand Line Pin
GetOn&GetGoing8-Feb-04 23:43
GetOn&GetGoing8-Feb-04 23:43 
GeneralRe: Command Line Pin
Heath Stewart9-Feb-04 1:30
protectorHeath Stewart9-Feb-04 1:30 
QuestionHow to execute a file Pin
Jonathan Slenders_8-Feb-04 22:41
sussJonathan Slenders_8-Feb-04 22:41 
AnswerRe: How to execute a file Pin
Mazdak8-Feb-04 23:20
Mazdak8-Feb-04 23:20 
GeneralRe: How to execute a file Pin
Jonathan Slenders9-Feb-04 0:22
Jonathan Slenders9-Feb-04 0:22 
GeneralRe: How to execute a file Pin
Heath Stewart9-Feb-04 1:28
protectorHeath Stewart9-Feb-04 1:28 
AnswerRe: How to execute a file Pin
Mike Clark9-Feb-04 12:13
Mike Clark9-Feb-04 12:13 
QuestionHow to reduce size? Pin
GetOn&GetGoing8-Feb-04 20:22
GetOn&GetGoing8-Feb-04 20:22 
AnswerRe: How to reduce size? Pin
Mazdak8-Feb-04 21:31
Mazdak8-Feb-04 21:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.