Click here to Skip to main content
15,911,142 members
Home / Discussions / C#
   

C#

 
GeneralRe: winform Deployment Pin
arkiboys9-Mar-11 21:21
arkiboys9-Mar-11 21:21 
AnswerRe: winform Deployment Pin
OriginalGriff9-Mar-11 22:08
mveOriginalGriff9-Mar-11 22:08 
GeneralRe: winform Deployment Pin
arkiboys9-Mar-11 22:10
arkiboys9-Mar-11 22:10 
AnswerRe: winform Deployment Pin
Pete O'Hanlon7-Mar-11 10:50
mvePete O'Hanlon7-Mar-11 10:50 
GeneralRe: winform Deployment Pin
arkiboys7-Mar-11 10:57
arkiboys7-Mar-11 10:57 
GeneralRe: winform Deployment Pin
GenJerDan7-Mar-11 12:16
GenJerDan7-Mar-11 12:16 
AnswerRe: winform Deployment Pin
RaviRanjanKr9-Mar-11 17:27
professionalRaviRanjanKr9-Mar-11 17:27 
QuestionStore data in Attribute for use in PropertyGrid Pin
lukeer7-Mar-11 1:22
lukeer7-Mar-11 1:22 
Hello experts,

I'd like to inform users of my software that a value entered in PropertyGrid is not valid.

Since the validity of that value depends on other properties, it's not an option to just don't change the value on user input. Therefore I plan on decorating the value with some error indicating icon.

I created an attribute with boolean value to remember if the error icon shall be shown.

On property value change the icon drawing value is set:
PropertyEditor.CalmdownWarningAttribute.SetValue(typeof(Foo).GetProperty("Speed1"), true);

public static void SetValue(System.Reflection.PropertyInfo property, bool value)
            {
                //An array of all attributes of type CalmdownWarning that
                // have been applied to this property.
                object[] attributes = property.GetCustomAttributes(typeof(PropertyEditor.CalmdownWarningAttribute), true);

                //If any CalmdownWarning attribute exists, return true.
                if (attributes.Length <= 0)
                    throw new Exception("Attribute \"ShowWarning\" is not set for property \"" + property.Name + "\".");

                // mark*
                ((CalmdownWarningAttribute)(attributes[0]))._calmdownWarning = value;
            }

Then a UITypeEditor is responsible for drawing the icon next to the erronuous value
public class ExclamationTypeEditor : System.Drawing.Design.UITypeEditor
    {
        public override bool GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context)
        {
            return(PropertyEditor.CalmdownWarningAttribute.IsSet(context.PropertyDescriptor));
        }


        public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e)
        {
            if (
                PropertyEditor.CalmdownWarningAttribute.IsSet(e.Context.PropertyDescriptor)
                // mark**
                && !PropertyEditor.CalmdownWarningAttribute.GetValue(e.Context.PropertyDescriptor)
            )
                e.Graphics.DrawImage(InterrollConfigurator.Properties.Resources.Exclamation, e.Bounds);
        }
    }

And here comes my problem:

The error indicating exclamation icon is always drawn.

I stepped through the code and found that at mark* the value is correctly set to true, but later, at mark**, it is back to its standard value false.

Am I trying a totally wrong approach?
Any hints on how to get icons next to PropertyGrid values changed at runtime?

Ciao,


luker

QuestionSCCM OS Deployment with native C# code Pin
UK19676-Mar-11 21:15
UK19676-Mar-11 21:15 
AnswerRe: SCCM OS Deployment with native C# code Pin
OriginalGriff7-Mar-11 0:46
mveOriginalGriff7-Mar-11 0:46 
GeneralRe: SCCM OS Deployment with native C# code Pin
UK19677-Mar-11 1:12
UK19677-Mar-11 1:12 
Questionerror with Button in datagridview Pin
dits056-Mar-11 18:57
dits056-Mar-11 18:57 
AnswerRe: error with Button in datagridview Pin
nainakarri7-Mar-11 0:06
nainakarri7-Mar-11 0:06 
AnswerRe: error with Button in datagridview Pin
Pravin Patil, Mumbai7-Mar-11 0:27
Pravin Patil, Mumbai7-Mar-11 0:27 
AnswerRe: error with Button in datagridview Pin
OriginalGriff7-Mar-11 0:38
mveOriginalGriff7-Mar-11 0:38 
QuestionWhat do programmers think about "Fluent Interface's" ? Pin
venomation6-Mar-11 16:14
venomation6-Mar-11 16:14 
AnswerRe: What do programmers think about "Fluent Interface's" ? Pin
Super Lloyd6-Mar-11 16:42
Super Lloyd6-Mar-11 16:42 
GeneralRe: What do programmers think about "Fluent Interface's" ? Pin
venomation6-Mar-11 17:10
venomation6-Mar-11 17:10 
AnswerRe: What do programmers think about "Fluent Interface's" ? Pin
Pete O'Hanlon6-Mar-11 19:46
mvePete O'Hanlon6-Mar-11 19:46 
GeneralRe: What do programmers think about "Fluent Interface's" ? Pin
venomation6-Mar-11 21:32
venomation6-Mar-11 21:32 
AnswerRe: What do programmers think about "Fluent Interface's" ? Pin
Eddy Vluggen6-Mar-11 20:51
professionalEddy Vluggen6-Mar-11 20:51 
GeneralRe: What do programmers think about "Fluent Interface's" ? Pin
venomation6-Mar-11 21:34
venomation6-Mar-11 21:34 
GeneralRe: What do programmers think about "Fluent Interface's" ? Pin
Eddy Vluggen7-Mar-11 0:12
professionalEddy Vluggen7-Mar-11 0:12 
GeneralRe: What do programmers think about "Fluent Interface's" ? Pin
venomation7-Mar-11 6:00
venomation7-Mar-11 6:00 
GeneralRe: What do programmers think about "Fluent Interface's" ? Pin
Eddy Vluggen7-Mar-11 8:14
professionalEddy Vluggen7-Mar-11 8:14 

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.