473,320 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

ValidateChildren on a tab control

Hi,

I'm very new to windows forms and C# so this is my first post in this
group :-) I have a very simple forms app with a tab control containing
two tabs. Its related to football and one tab relates to players and
the other tab to teams. I'm using the ErrorProvider component to
display error information which I set in the Validating handlers for
the controls that need validating.

I set the form to AutoValidate.EnableAllowFocusChange and then in my
button that I want the validation performed in (I have a save button
in each tab) I was hoping I could use the ValidateChildren method to
invoke all of those handlers. The problem is that ValidateChildren
would seem to only apply to the form as a whole and I want to treat
the controls on each tab separately. Of course what is happening is
that if the user enters some data in the player tab for example and
tries to save it, the validation events for the teams tab also kick in
and if those controls are empty then the form as a whole is invalid.

The tab control doesn't seem to have a ValidateChildren function and I
can't seem to find any way of grouping them. According to the docs I
should be able to call the method on any class that is a
ContainerControl but I dont know of any classes that are derived from
that one!

Any help much appreciated,

Caroline M.

Jan 31 '07 #1
3 6960
On 31 Jan 2007 01:50:50 -0800, "Caroline M"
<ca******************@googlemail.comwrote:
>Hi,

I'm very new to windows forms and C# so this is my first post in this
group :-) I have a very simple forms app with a tab control containing
two tabs. Its related to football and one tab relates to players and
the other tab to teams. I'm using the ErrorProvider component to
display error information which I set in the Validating handlers for
the controls that need validating.

I set the form to AutoValidate.EnableAllowFocusChange and then in my
button that I want the validation performed in (I have a save button
in each tab) I was hoping I could use the ValidateChildren method to
invoke all of those handlers. The problem is that ValidateChildren
would seem to only apply to the form as a whole and I want to treat
the controls on each tab separately. Of course what is happening is
that if the user enters some data in the player tab for example and
tries to save it, the validation events for the teams tab also kick in
and if those controls are empty then the form as a whole is invalid.

The tab control doesn't seem to have a ValidateChildren function and I
can't seem to find any way of grouping them. According to the docs I
should be able to call the method on any class that is a
ContainerControl but I dont know of any classes that are derived from
that one!

Any help much appreciated,

Caroline M.
Good morning Caroline,

Have you tried setting the Tab's CausesValidation property to false?

When using validation you can set controls that way to prevent them from
validating data on the form. One example of that would be to set a Cancel
button's CausesValidation property to false, because if the user cancels a form
there is normally no validation required. I would think in your case the same
is true of the tab tabs you are using. I can't think of why you would need to
validate on the selection of tabs.

I think a good rule to follow when using the validation controls is that if a
control is used for nothing but navigation it should not cause validation to
occur. On the other hand validation should occur when the user takes an action
that would submit the data to storage (clicking the OK button or something like
that).
Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
Jan 31 '07 #2
Have you tried setting the Tab's CausesValidation property to false?

No
is true of the tab tabs you are using. I can't think of why you would need to
validate on the selection of tabs.
I need the validation depending on the context of the tab. If the user
is on the player tab then I want to ensure that all the player-related
controls on that tab are validated. Likewise for the teams tab. But of
course if I am on the player tab, I dont care about the team controls
in that context.
I think a good rule to follow when using the validation controls is that if a
control is used for nothing but navigation it should not cause validation to
occur. On the other hand validation should occur when the user takes an action
No these are data-input type controls, not used for navigation.
Good luck with your project,
Thanks :)

Caroline

Jan 31 '07 #3
On 31 Jan 2007 06:35:02 -0800, "Caroline M"
<ca******************@googlemail.comwrote:
>Have you tried setting the Tab's CausesValidation property to false?

No
>is true of the tab tabs you are using. I can't think of why you would need to
validate on the selection of tabs.

I need the validation depending on the context of the tab. If the user
is on the player tab then I want to ensure that all the player-related
controls on that tab are validated. Likewise for the teams tab. But of
course if I am on the player tab, I dont care about the team controls
in that context.
>I think a good rule to follow when using the validation controls is that if a
control is used for nothing but navigation it should not cause validation to
occur. On the other hand validation should occur when the user takes an action

No these are data-input type controls, not used for navigation.
>Good luck with your project,

Thanks :)

Caroline
OK,

I think you might have misunderstood what I meant by navigation. In my mind
navigation controls are buttons and tabs. But as Dennis Miller frequently
say's, "That's just my opinion. I could be wrong.".

Good luck with your project,

Otis Mukinfus

http://www.otismukinfus.com
http://www.arltex.com
http://www.tomchilders.com
http://www.n5ge.com
Jan 31 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Bruce Rusk | last post by:
I'm using Stephen Lebans' RTF2 control in a report, and have discovered what may be a slight bug in it. I have a lot of non-Western language (Chinese) text in my RTF field, and such records get...
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
20
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just...
5
by: serge calderara | last post by:
Dear all, I am new in asp.net and prepare myself for exam I still have dificulties to understand the difference between server control and HTML control. Okey things whcih are clear are the fact...
2
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
4
by: gsb58 | last post by:
Hi! On a form I have a calendar. The form is rezised to 1024x768 (Don't worry - this is a training case) when loaded. Now I want to center the calendar on the form so that its edges are...
5
by: paul.hester | last post by:
Hi all, I have a custom control with an overridden Render method. Inside this method I'm rendering each control in its collection using their RenderControl method. However, I'm running into a...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.