WinForm Question

G

Guest

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
 

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