I am new and trying to learn C#.
My children gave me the booklet (Learning to program in C #) to teach myself, but I'm getting stuck now.
Now I need to create a form, with a DateTimePicker a Button and a checkBox.
The question is :
If the DateTimePicker (dtpGeboorteDatum) has changed, there must be a check mark in the
associated checkBox (checkBoxA1).”
I got the following example that I need to use.
dtpGeboorteDatum.Enabled = checkBoxA1.Checked;
My children gave me the booklet (Learning to program in C #) to teach myself, but I'm getting stuck now.
Now I need to create a form, with a DateTimePicker a Button and a checkBox.
The question is :
If the DateTimePicker (dtpGeboorteDatum) has changed, there must be a check mark in the
associated checkBox (checkBoxA1).”
I got the following example that I need to use.
dtpGeboorteDatum.Enabled = checkBoxA1.Checked;
C#:
private void btnGeboorteDatum_Click(object sender, EventArgs e)
{
DateTime leeftijd = DateTime.Now;
DateTime geboortedatum = dtpGeboorteDatum.Value;
if (leeftijd <= geboortedatum.AddYears (18))
{
dtpGeboorteDatum.Enabled = checkBoxA1.Checked;
MessageBox.Show("Je mag nog niet auto rijden");
}
else
{
MessageBox.Show("Je mag auto rijden");
}
}