• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 153
  • Last Modified:

passing dates from the calender to text box

I have a calendar control on the form by name MonthCalendar1

I have two text boxes. I'm trying to pass two dates like start and end date into the text boxes 1 and 2. For that I did like this

Private Sub MonthCalendar1_DateChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateChanged
        txtstartdate.Text = MonthCalendar1.SelectionStart
        txtenddate.text = MonthCalendar1.Selectionend
end sub

BUT WHEN I SELECT THE FIRST TIME IT COPIES TO BOTH TEXTBOXES. HOW TO GET THE SECOND SELECTION DATE TO SECOND TEXTBOX.

Thanks
VM
0
vmandem
Asked:
vmandem
  • 2
  • 2
1 Solution
 
Brian CroweDatabase AdministratorCommented:
try using the DateSelected event instead

"This event is similar to DateChanged, but it occurs at the end of a date selection made using the mouse. The DateChanged event occurs during any date selection, whether by mouse, keyboard, or code."
0
 
vmandemAuthor Commented:
BriCrowe,

It does the same. No change

VM
0
 
TorrwinCommented:
I just use two calendar controls.  One for the start date, and one for the end date.
0
 
Brian CroweDatabase AdministratorCommented:
try this...

private startDate as boolean = true

Private Sub MonthCalendar1_DateChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateChanged
    If startDate Then
        txtstartdate.Text = MonthCalendar1.SelectionStart
        startDate = false
    Else
        txtenddate.text = MonthCalendar1.Selectionend
        startDate = true
   End If
end sub
0
 
vmandemAuthor Commented:
BriCrowe

This one works fine, what If I want to change the firstdate through the calender. The above code changes only for second date. I'm disabling the textboxes for the users to edit and choose only from calendar.

Thanks
VM
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now