Click here to Skip to main content
15,887,350 members
Home / Discussions / C#
   

C#

 
QuestionPassing object[] Elements as Parameters to Invoke() Pin
ezazazel3-Oct-12 7:04
ezazazel3-Oct-12 7:04 
AnswerRe: Passing object[] Elements as Parameters to Invoke() Pin
Matt T Heffron3-Oct-12 9:08
professionalMatt T Heffron3-Oct-12 9:08 
GeneralRe: Passing object[] Elements as Parameters to Invoke() Pin
ezazazel3-Oct-12 19:26
ezazazel3-Oct-12 19:26 
QuestionC# calling executable Pin
dcof3-Oct-12 3:57
dcof3-Oct-12 3:57 
AnswerRe: C# calling executable Pin
Pete O'Hanlon3-Oct-12 4:16
mvePete O'Hanlon3-Oct-12 4:16 
AnswerRe: C# calling executable Pin
Shameel3-Oct-12 4:51
professionalShameel3-Oct-12 4:51 
AnswerRe: C# calling executable Pin
Dave Kreskowiak3-Oct-12 5:35
mveDave Kreskowiak3-Oct-12 5:35 
GeneralRe: C# calling executable Pin
dcof3-Oct-12 8:07
dcof3-Oct-12 8:07 
GeneralRe: C# calling executable Pin
Pete O'Hanlon3-Oct-12 8:38
mvePete O'Hanlon3-Oct-12 8:38 
GeneralRe: C# calling executable Pin
Dave Kreskowiak3-Oct-12 13:45
mveDave Kreskowiak3-Oct-12 13:45 
QuestionC# Windows application not responding after 30 minutes Pin
sujithkumarsl2-Oct-12 10:13
sujithkumarsl2-Oct-12 10:13 
AnswerRe: C# Windows application not responding after 30 minutes Pin
Smart Arab2-Oct-12 10:58
Smart Arab2-Oct-12 10:58 
AnswerRe: C# Windows application not responding after 30 minutes Pin
Dave Kreskowiak2-Oct-12 12:35
mveDave Kreskowiak2-Oct-12 12:35 
GeneralOT Pin
Peter_in_27802-Oct-12 22:08
professionalPeter_in_27802-Oct-12 22:08 
GeneralRe: OT Pin
Dave Kreskowiak3-Oct-12 2:22
mveDave Kreskowiak3-Oct-12 2:22 
GeneralRe: OT Pin
Peter_in_27803-Oct-12 2:29
professionalPeter_in_27803-Oct-12 2:29 
GeneralRe: OT Pin
Dave Kreskowiak3-Oct-12 5:24
mveDave Kreskowiak3-Oct-12 5:24 
GeneralRe: C# Windows application not responding after 30 minutes Pin
sujithkumarsl3-Oct-12 4:36
sujithkumarsl3-Oct-12 4:36 
GeneralRe: C# Windows application not responding after 30 minutes Pin
sujithkumarsl3-Oct-12 4:51
sujithkumarsl3-Oct-12 4:51 
AnswerRe: C# Windows application not responding after 30 minutes Pin
DaveyM693-Oct-12 4:21
professionalDaveyM693-Oct-12 4:21 
GeneralRe: C# Windows application not responding after 30 minutes Pin
sujithkumarsl3-Oct-12 4:41
sujithkumarsl3-Oct-12 4:41 
GeneralRe: C# Windows application not responding after 30 minutes Pin
DaveyM694-Oct-12 0:34
professionalDaveyM694-Oct-12 0:34 
GeneralRe: C# Windows application not responding after 30 minutes Pin
sujithkumarsl4-Oct-12 10:17
sujithkumarsl4-Oct-12 10:17 
QuestionTextbox validation c# help Pin
User 94041062-Oct-12 8:57
User 94041062-Oct-12 8:57 
AnswerRe: Textbox validation c# help Pin
Matt T Heffron2-Oct-12 10:38
professionalMatt T Heffron2-Oct-12 10: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:
C#
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
C#
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.)

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

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