user2631662 user2631662 - 17 days ago 8
C# Question

definition for 'Value' accepting a first argument of type '' could not be found

Hi I want to display the selected date from my datetimepicker in a textbox. I have tried the following but get the error on value: DatePicker does not contain a definition for 'Value' accepting a first argument of type '' could not be found..

private void datePicker_ValueChanged(object sender, EventArgs e)
{

DateTime date = this.datePicker.Value;

this.txtExpire.Text = date.ToString("dd-mm-yyyy");

}

Answer

Use DateTime? date = this.datePicker.SelectedDate instead of Value.