5

I have two textbox to let user input start date and end date. Then I have a checkbox that allow user to check to see some calculations. My question is, how can I disable the checkbox if the duration between start date and end date is shorter than a specific length. I mean, right after user input the start date and end date, he/she would see the checkbox is disabled because the time period length is not long enough.

if (productWealth.Count < 3)
    checkBox7.Enabled = false;

This is what I have now, if count < 3, then checkbox 7 is disabled. Seems like the application only run the count when run click the RUN button, but I want them to see immediate effect.

1
  • WinForms? WebForms? Give us a clue, at least. Also, one line of code isn't enough to know what's going on. Commented Sep 23, 2013 at 18:50

2 Answers 2

2

You can use the event TextChanged, so when the user change the value of the TextBox you check if its true and enable the CheckBox.

tboxEndDate.TextChanged += new TextChangedEventHandler(tboxEndDate_TextChanged);

void tboxEndDate_TextChanged(object sender, TextChangedEventArgs e)
{
   // Calcule the productWealth
   if (productWealth.Count < 3) checkBox7.Enabled = false;
}
Sign up to request clarification or add additional context in comments.

Comments

0

Look at the Leave() event for your start and end date textboxes. Place your if() statement in there.

Uh that is, if this is WinForms...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.