Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Multiple MonthCalendars in a form - does not keep all dates in each textbox

Multiple MonthCalendars in a form - does not keep all dates in each textbox

Scheduled Pinned Locked Moved Visual Basic
linqcsharpdatabasevisual-studiohelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PrissySC
    wrote on last edited by
    #1

    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.ToShortDateString

    MonthCalendarPO.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 Sub

    I 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?

    L 1 Reply Last reply
    0
    • P PrissySC

      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.ToShortDateString

      MonthCalendarPO.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 Sub

      I 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?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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.ToShortDateString

      MonthCalendarPO.Visible = False
      

      End Sub

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

      P 1 Reply Last reply
      0
      • L Lost User

        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.ToShortDateString

        MonthCalendarPO.Visible = False
        

        End Sub

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

        P Offline
        P Offline
        PrissySC
        wrote on last edited by
        #3

        Thanks again. What would I do without your brain. :) I was not even looking at the string development in any manner. I should have known that. My languages are a little mixed up some days. Dumb newbie thing ... LOL

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups