0

Windows Form Application C#

I have four TextBox on windows Form. i have written code to handle Text_Validating event for each textbox. Now when user clicks on submit Button i want those text_validating events to fire automatically.

Enabled CausesValidation property of Button.

We have something called validationGroup Property in ASP.net how it can be implemented in windows application

pls help me to solve this problem

thank you

KB5
  • 128
  • 3
  • 12

4 Answers4

0

One option is simply to call the validation method passing in a parameters necessary (nulls might work - showing code would help to determine if necessary).

Brad Semrad
  • 1,501
  • 1
  • 11
  • 19
0

I believe the Text_Validating event only fires when a control's focus changes. If you are interested in validation on submit you could do something which is proposed by user Bruce from this post.

Community
  • 1
  • 1
Ben.Vineyard
  • 1,149
  • 8
  • 14
0

Also, you can write own Validator controls like asp.net in Winforms with following validators:- .

RequiredFieldValidator  
RegularExpressionValidator  
CompareValidator    
RangeValidator  
CustomValidator

Here is a step by step explanation and walkthrough on how to extend Winforms with a custom validation library - http://msdn.microsoft.com/en-us/library/ms950965.aspx

Angshuman Agarwal
  • 4,796
  • 7
  • 41
  • 89
0

On button click, go with:

if(ValidateChildren())
{
      //do stuff
}
Unheilig
  • 16,196
  • 193
  • 68
  • 98
Danilo
  • 1