Click here to Skip to main content
15,910,980 members
Home / Discussions / C#
   

C#

 
AnswerRe: Convert string to datetime Pin
GenJerDan15-Jun-11 11:30
GenJerDan15-Jun-11 11:30 
GeneralRe: Convert string to datetime Pin
AspDotNetDev15-Jun-11 11:40
protectorAspDotNetDev15-Jun-11 11:40 
GeneralRe: Convert string to datetime Pin
GenJerDan16-Jun-11 3:18
GenJerDan16-Jun-11 3:18 
AnswerRe: Convert string to datetime Pin
V.15-Jun-11 20:04
professionalV.15-Jun-11 20:04 
QuestionUndo changes to context when using EntityFramework 4.0/4.1 Pin
MaWeRic15-Jun-11 5:59
MaWeRic15-Jun-11 5:59 
AnswerRe: Undo changes to context when using EntityFramework 4.0/4.1 Pin
dasblinkenlight15-Jun-11 8:33
dasblinkenlight15-Jun-11 8:33 
AnswerRe: Undo changes to context when using EntityFramework 4.0/4.1 Pin
AspDotNetDev15-Jun-11 9:45
protectorAspDotNetDev15-Jun-11 9:45 
Question[Solved] PropertyGrid with multiple SelectedObjects [modified] Pin
lukeer15-Jun-11 4:31
lukeer15-Jun-11 4:31 
Hi experts,

there is a PropertyGrid in my application. It shows properties of an object. Some of these properties can hold values that are illegal to business logic. Those values show a warning symbol by using a custom TypeEditor. Mentioned properties are marked by an attribute.

Some of the properties are even linked. Business logic decides whether or not a combination of linked properties is illegal.

To this point all is fine.

Now the PropertyGrid has to show properties of multiple objects and the warning symbols don't work any longer.

This method should tell whether a property can, depending on its value, warn by setting the symbol
public override bool GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context)
{
    // First chance: "Invalid" enumeration value
    if (
        context.PropertyDescriptor.PropertyType.IsEnum
        && Enum.IsDefined(context.PropertyDescriptor.PropertyType, "Invalid")
    )
        return(true);

    // Second chance: decorated with WarnableAttribute
    foreach(Attribute attribute in context.PropertyDescriptor.Attributes) //mark
        if(attribute is WarnableAttribute)
            return(true);

    // No support for drawing icon.
    return (false);
}
The marked line fails for multiple objects.context.PropertyDescriptor is a PropertyGridInternal.MergePropertyDescriptor, which is not accessible due to access levels.

How could I test for an icon to be painted?


Edit: It's working now thanks to ITypeDescriptorContext containing an object called instance, which is an Array when selecting multiple objects.
Knowing that, it's possible to check for attributes with some reflection.

Ciao,


luker
modified on Friday, June 17, 2011 3:19 AM

QuestionC# webservice Pin
Member 401661615-Jun-11 4:09
Member 401661615-Jun-11 4:09 
AnswerRe: C# webservice Pin
Not Active15-Jun-11 4:15
mentorNot Active15-Jun-11 4:15 
AnswerRe: C# webservice Pin
BobJanova15-Jun-11 4:26
BobJanova15-Jun-11 4:26 
QuestionDownload with httpwebrequest/response and stream Pin
Muli10015-Jun-11 3:32
Muli10015-Jun-11 3:32 
AnswerRe: Download with httpwebrequest/response and stream Pin
BobJanova15-Jun-11 4:08
BobJanova15-Jun-11 4:08 
GeneralRe: Download with httpwebrequest/response and stream Pin
Muli10015-Jun-11 4:20
Muli10015-Jun-11 4:20 
GeneralRe: Download with httpwebrequest/response and stream Pin
BobJanova15-Jun-11 4:25
BobJanova15-Jun-11 4:25 
GeneralRe: Download with httpwebrequest/response and stream Pin
Muli10016-Jun-11 0:40
Muli10016-Jun-11 0:40 
QuestionHow to Create Zoom In/Out for Text Pin
Anubhava Dimri15-Jun-11 2:16
Anubhava Dimri15-Jun-11 2:16 
AnswerRe: How to Create Zoom In/Out for Text Pin
BobJanova15-Jun-11 3:09
BobJanova15-Jun-11 3:09 
AnswerRe: How to Create Zoom In/Out for Text Pin
OriginalGriff15-Jun-11 3:27
mveOriginalGriff15-Jun-11 3:27 
GeneralRe: How to Create Zoom In/Out for Text Pin
BobJanova15-Jun-11 4:05
BobJanova15-Jun-11 4:05 
QuestionIs it possible to change the remote SQL Server Job Start time in C# Pin
Vimalsoft(Pty) Ltd14-Jun-11 23:19
professionalVimalsoft(Pty) Ltd14-Jun-11 23:19 
AnswerRe: Is it possible to change the remote SQL Server Job Start time in C# Pin
Blue_Boy14-Jun-11 23:35
Blue_Boy14-Jun-11 23:35 
GeneralRe: Is it possible to change the remote SQL Server Job Start time in C# Pin
Vimalsoft(Pty) Ltd15-Jun-11 3:24
professionalVimalsoft(Pty) Ltd15-Jun-11 3:24 
GeneralRe: Is it possible to change the remote SQL Server Job Start time in C# Pin
Blue_Boy15-Jun-11 4:01
Blue_Boy15-Jun-11 4:01 
AnswerRe: Is it possible to change the remote SQL Server Job Start time in C# Pin
jschell15-Jun-11 9:01
jschell15-Jun-11 9:01 

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.