I change it to
DateA.DataBindings.Add("text", datetimepicker.Value, "Date", True, DataSourceUpdateMode.OnValidation, "", "MM/dd/yy").DataSourceUpdateMode = DataSourceUpdateMode.OnValidation
and is fine
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
In VB 2019 in a form, I set up that a date is selected from a datetimepicker, and the selected date has to be brought into the textbox named "DateA".
If I use the following code,
DateA.Text = FormatDateTime(Convert.ToDateTime(datetimepicker.Value), DateFormat.ShortDate)
I get an error message "
'Unable to cast object of type 'System.EventArgs' to type
So I used databinding, as follows
Me.DateA.DataBindings.Clear()
DateA.DataBindings.Add("text", datetimepicker.Value, "Value", True, DataSourceUpdateMode.OnValidation, "", "MM/dd/yy").DataSourceUpdateMode = DataSourceUpdateMode.OnValidation
But when I run it, the message is "
'Cannot bind to the property or column "Value" on the DataSource"
So what do I need to write instead of "Value", because when using Value, it generates an error message.
I change it to
DateA.DataBindings.Add("text", datetimepicker.Value, "Date", True, DataSourceUpdateMode.OnValidation, "", "MM/dd/yy").DataSourceUpdateMode = DataSourceUpdateMode.OnValidation
and is fine