WinForm validation

M

Marek

Hi all,

who can give me an answer on this question: how to validate controls on
WinForm? So clicking on AceptButton does not return control from WinForm to
program until all controls have proper values.

TIA,

MP
 
F

Frans Bouma [C# MVP]

Marek said:
Hi all,

who can give me an answer on this question: how to validate controls
on WinForm? So clicking on AceptButton does not return control from
WinForm to program until all controls have proper values.

create a check routine which checks all controls which have to be
valid. let that routine return true if everything is valid, false
otherwise.

now for each control that has to be valid, add a handler to the
changed event of the control (selected index changed, text changed etc.
)
In that handler simply do:
_acceptButton.Enabled = CheckRoutine();

and you set _acceptButton as disabled by default when the form starts.

FB


--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
 

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