Click here to Skip to main content
11,408,835 members (61,841 online)
   

C#

 
GeneralRe: C# Windows application not responding after 30 minutes Pinmembersujithkumarsl3-Oct-12 5:36 
GeneralRe: C# Windows application not responding after 30 minutes Pinmembersujithkumarsl3-Oct-12 5:51 
AnswerRe: C# Windows application not responding after 30 minutes PinmentorDaveyM693-Oct-12 5:21 
GeneralRe: C# Windows application not responding after 30 minutes Pinmembersujithkumarsl3-Oct-12 5:41 
GeneralRe: C# Windows application not responding after 30 minutes PinmentorDaveyM694-Oct-12 1:34 
GeneralRe: C# Windows application not responding after 30 minutes Pinmembersujithkumarsl4-Oct-12 11:17 
QuestionTextbox validation c# help PinmemberRobbie Kleman2-Oct-12 9:57 
AnswerRe: Textbox validation c# help PinmemberMatt T Heffron2-Oct-12 11:38 
Your ValidateText will set the Successful to indicate if the last entry in the textbox list is valid or not. All the checking of the earlier entries is lost.
Try something like:
public void ValidateText(List<TextBox> textboxes)
{
  Successful = true;    // Assume all are valid until shown otherwise
  foreach (var tb in textboxes)
  {
    if (string.IsNullOrEmpty(tb.Text))  // could also use .IsNullOrWhiteSpace()
    {
      Successful = false;       // this means that at least 1 is failing.
      // collect the failing ones here
    }
  }
}
and then
  List<TextBox> textboxes = new List<TextBox>();
  textboxes.Add(FirstNTxt);
  textboxes.Add(LastNTxt);
  textboxes.Add(CourseTxt);
  //validation
  FormValidation validate = new FormValidation();
  validate.ValidateText(textboxes);
  if(!validate.Successful)
  {
    MessageBox.Show("error");
  }
  else
  {
    //more stuff that i did not paste in.
  }
Personally, I'd probably make a validation method that operates on one string at a time and then validate and set the errorprovider directly for each TextBox one at a time. (Despite what I showed above, I wouldn't pass the actual TextBox references around. The method should validate the string, possibly returning an error message. The caller (form) passes the .Text and reports the error appropriately.)
AnswerRe: Textbox validation c# help PinmemberSmart Arab2-Oct-12 12:17 
GeneralRe: Textbox validation c# help PinmemberRobbie Kleman2-Oct-12 12:27 
GeneralRe: Textbox validation c# help PinmemberRobbie Kleman8-Oct-12 4:37 
QuestionMonitoring file changes and changing data within the file... PinmemberJD862-Oct-12 9:31 
AnswerRe: Monitoring file changes and changing data within the file... PinmemberSmart Arab2-Oct-12 12:22 
GeneralRe: Monitoring file changes and changing data within the file... PinprotectorPete O'Hanlon3-Oct-12 3:03 
AnswerRe: Monitoring file changes and changing data within the file... PinmemberEddy Vluggen3-Oct-12 2:39 
AnswerRe: Monitoring file changes and changing data within the file... PinprotectorPete O'Hanlon3-Oct-12 3:26 
GeneralRe: Monitoring file changes and changing data within the file... PinmvpDave Kreskowiak3-Oct-12 6:33 
GeneralRe: Monitoring file changes and changing data within the file... PinprotectorPete O'Hanlon3-Oct-12 6:37 
GeneralRe: Monitoring file changes and changing data within the file... PinmvpDave Kreskowiak3-Oct-12 14:38 
AnswerRe: Monitoring file changes and changing data within the file... PinmemberBobJanova3-Oct-12 3:42 
GeneralRe: Monitoring file changes and changing data within the file... PinprotectorPete O'Hanlon3-Oct-12 4:10 
GeneralRe: Monitoring file changes and changing data within the file... PinmemberJD863-Oct-12 14:59 
GeneralRe: Monitoring file changes and changing data within the file... PinmemberJD8612-Oct-12 6:27 
QuestionC# setup and deploy project templates located at? Pinmemberdcof2-Oct-12 6:10 
AnswerRe: C# setup and deploy project templates located at? Pinmemberisenthil2-Oct-12 7:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.150414.5 | Last Updated 24 Apr 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid