WinForm validation

  • Thread starter Thread starter Marek
  • Start date Start date
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
 
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#)
------------------------------------------------------------------------
 
Back
Top