Multiple MonthCalendars in a form - does not keep all dates in each textbox
-
I have four textboxes. Each one is filled by selecting a date from the monthcalendar (VS win form). While I handled most of the problems, such as a dbnull, I discovered this little "oops". I use the same type of handle for each daterangeevetargs:
Private Sub MonthCalendarPO_DateSelected(sender As Object, e As DateRangeEventArgs) Handles MonthCalendarPO.DateSelected
JobPOdateTextBox.Text = e.Start.ToShortDateStringMonthCalendarPO.Visible = False
End Sub
A click of a picture box to hide and show the calendar:
Private Sub PictureBoxPO_Click(sender As Object, e As EventArgs) Handles PictureBoxPO.Click
If MonthCalendarPO.Visible = False Then
MonthCalendarPO.Visible = True
Else
MonthCalendarPO.Visible = False
End If
End SubI removed the custom validation too. So, I will not post. The problem exists even without checking the date format. Each date is filled and visible in a textbox. Yet, when clicking the "save" button, only one date will remain in a textbox and save on submit changes (dates are bound to a bindingsource). As I have read and and read some more, I feel it must be the daterangeeventargs.:confused: Worth noting, if you manually enter the date into the textboxes, all four dates will save on submit changes. For now, I have resolved to a submit changes to the database after each date selection. This is certainly not ideal or a good practice. Bindingsource is filled as system.linq.iqueryable(of namespace.tablename). Data class is Linq2SQL. Any ideas on why this type of behavior is experienced?
-
I have four textboxes. Each one is filled by selecting a date from the monthcalendar (VS win form). While I handled most of the problems, such as a dbnull, I discovered this little "oops". I use the same type of handle for each daterangeevetargs:
Private Sub MonthCalendarPO_DateSelected(sender As Object, e As DateRangeEventArgs) Handles MonthCalendarPO.DateSelected
JobPOdateTextBox.Text = e.Start.ToShortDateStringMonthCalendarPO.Visible = False
End Sub
A click of a picture box to hide and show the calendar:
Private Sub PictureBoxPO_Click(sender As Object, e As EventArgs) Handles PictureBoxPO.Click
If MonthCalendarPO.Visible = False Then
MonthCalendarPO.Visible = True
Else
MonthCalendarPO.Visible = False
End If
End SubI removed the custom validation too. So, I will not post. The problem exists even without checking the date format. Each date is filled and visible in a textbox. Yet, when clicking the "save" button, only one date will remain in a textbox and save on submit changes (dates are bound to a bindingsource). As I have read and and read some more, I feel it must be the daterangeeventargs.:confused: Worth noting, if you manually enter the date into the textboxes, all four dates will save on submit changes. For now, I have resolved to a submit changes to the database after each date selection. This is certainly not ideal or a good practice. Bindingsource is filled as system.linq.iqueryable(of namespace.tablename). Data class is Linq2SQL. Any ideas on why this type of behavior is experienced?
The handler is overwriting the data in the textbox when it is called. Change it to a concatenation;
Private Sub MonthCalendarPO_DateSelected(sender As Object, e As DateRangeEventArgs) Handles MonthCalendarPO.DateSelected
JobPOdateTextBox.Text += e.Start.ToShortDateStringMonthCalendarPO.Visible = False
End Sub
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
-
The handler is overwriting the data in the textbox when it is called. Change it to a concatenation;
Private Sub MonthCalendarPO_DateSelected(sender As Object, e As DateRangeEventArgs) Handles MonthCalendarPO.DateSelected
JobPOdateTextBox.Text += e.Start.ToShortDateStringMonthCalendarPO.Visible = False
End Sub
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]