[RESOLVED] how to call MonthCalendar1_DateSelected from another form
Hi Guys,
I have a month calendar on my form. under it's DateSelected Event I do a bunch of stuff. Now I want to call this event from another form. How can I do this?
Code:
Private Sub MonthCalendar1_DateSelected(ByVal sender As Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateSelected
....
End Sub
Re: how to call MonthCalendar1_DateSelected from another form
Change Private to Public (or Friend in your code) and call it:
vb.net Code:
' Must be known before the call is made
Dim startDate As Date = #1/1/2010#
Dim endDate As Date = #1/31/2010#
' Prepare the event arguments:
Dim e As New DateRangeEventArgs(startDate, endDate)
' FormName here is a placeholder for your actual form that contains your MonthCalendar.
Call FormName.MonthCalendar1_DateSelected(me, e)
Re: how to call MonthCalendar1_DateSelected from another form
thanks cicatrix:afrog:
I want the start and end date to be the current selected date of my month calendar. will try and figure it out now.
Re: how to call MonthCalendar1_DateSelected from another form
How about using properties
vb.net Code:
Public ReadOnly Property StartDate() As String
Get
Return txtStartDate.Text
End Get
End Property
Public ReadOnly Property EndDate() As String
Get
Return txtEndDate.Text
End Get
End Property
then call them from whereever
Code:
'form form2
txtStartDate.Text = Form1.StartDate
txtEndDate.Text = Form1.EndDate
Re: how to call MonthCalendar1_DateSelected from another form
thanks guys. problem has been resolved:wave: