TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
san
NA
19
0
Recursion Problem - breaking out
Jan 14 2008 5:37 PM
I have a recursive Function, which recurses through all the Controls on the Windows form, checks if there is an Error Message Associated with a textbox, and then returns a bool.
How do I break out of the recursive function the first instance an error message is encountered? What am I doing wrong? Here is the code below -
public bool RX(Control Ctrlx)
{
bool InvalidIPX = false;
try
{
foreach (Control G in Ctrlx.Controls)
{
if (G is TextBox)
{
if (ErrorProvider.GetError(Ctrl).Length != 0)
{
InvalidIPX = true;
break;
}
}
RX(G);
}
return InvalidIPX;
}
catch (Exception ex)
{
Console.WriteLine("{0} Exception Caught", ex);
return InvalidIPX;
}
}
Reply
Answers (
8
)
Synchronizing StreamWriter
Adding Dynamic Row In GridView by Enter KeyPress in ASP.Net and C#