ErrorProviders - Icon Change at Run-Time

S

Steve Le Monnier

My user interface design requires that ErrorProviders are used for errors
but also to indicate warnings to the users as well. In order to provide a
clear visual clue between errors and warnings its necessary to have two
differing icons.

I could place two ErrorProviders on my form, but what I would really like to
do is switch the Icon on the ErrorProvider control at run-time. But I am
having difficulty in understanding the syntax required to point the
ErrorProvider icon property at an Icon embedded inside the project assembly.

Does anybody have an suggestions on the syntax required to achieve this?

Many thanks

Steve Le Monnier
 
O

Oliver Sturm

Steve said:
My user interface design requires that ErrorProviders are used for errors
but also to indicate warnings to the users as well. In order to provide a
clear visual clue between errors and warnings its necessary to have two
differing icons.

I could place two ErrorProviders on my form, but what I would really like
to do is switch the Icon on the ErrorProvider control at run-time. But I
am having difficulty in understanding the syntax required to point the
ErrorProvider icon property at an Icon embedded inside the project
assembly.

Does anybody have an suggestions on the syntax required to achieve this?

This MS knowledge base article should have all the information you need:
http://support.microsoft.com/Default.aspx?id=319292

However, I have done the same thing in the past and I've found it more
practicable to use two different error providers - not so much switching
code, and the code is easier to understand because it's plain to see what
provider is used in a specific error/warning situation.


Oliver Sturm
 
S

Steve Le Monnier

Thanks for the advice Oliver I will do some additional tests before deciding
what to do.

FYI: My post was a simplification of what I am trying to achieve. I'm not
dragging the ErrorProviders onto a form I am actually embedding them
directly inside my own TextBox control, that's the reason why I don't want
to overload the control with four versions of the error provider when I know
only one can ever be active at any one time.

By having ErrorProviders built into a textbox control I can centralise some
of the standard data validation I do on every single project I work on. This
should allow me to reduce the amount of form validation code I end up
writing.

Cheers

Steve Le Monnier
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top