PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms WinForm Question

Reply

WinForm Question

 
Thread Tools Rate Thread
Old 20-01-2004, 05:15 PM   #1
Guest
 
Posts: n/a
Default WinForm Question


Hi,

I am trying to validate a form with two tab pages by looping through each
control on the form and setting focus to it. I am running into a problem,
each time I loop to a control on the tab page not selected it does not fire
the validating the event. I am confused why this is happening and was
wondering if there is a way around this. I have tried to use
ctl.TopLevelControl property to get the tabpage and then call the Show
method. However, this does not work very well. Here is the code below I
use: formControls is an array of Controls that I create in a method that
retrieves all the controls including subcontrols on the form.

foreach (Control ctl in formControls)
{
if (ctl.CausesValidation)
{
ctl.Focus();
if(!this.Validate())
{
break;
}
}
}

Thanks


  Reply With Quote
Old 20-01-2004, 09:25 PM   #2
Guest
 
Posts: n/a
Default Re: WinForm Question

Nevermind I figured it out.

<eric> wrote in message news:up5xGk33DHA.1052@TK2MSFTNGP12.phx.gbl...
> Hi,
>
> I am trying to validate a form with two tab pages by looping through each
> control on the form and setting focus to it. I am running into a problem,
> each time I loop to a control on the tab page not selected it does not

fire
> the validating the event. I am confused why this is happening and was
> wondering if there is a way around this. I have tried to use
> ctl.TopLevelControl property to get the tabpage and then call the Show
> method. However, this does not work very well. Here is the code below I
> use: formControls is an array of Controls that I create in a method that
> retrieves all the controls including subcontrols on the form.
>
> foreach (Control ctl in formControls)
> {
> if (ctl.CausesValidation)
> {
> ctl.Focus();
> if(!this.Validate())
> {
> break;
> }
> }
> }
>
> Thanks
>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off