Results 1 to 5 of 5

Thread: [RESOLVED] how to call MonthCalendar1_DateSelected from another form

  1. #1

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Resolved [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

  2. #2
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Re: how to call MonthCalendar1_DateSelected from another form

    Change Private to Public (or Friend in your code) and call it:

    vb.net Code:
    1. ' Must be known before the call is made
    2. Dim startDate As Date = #1/1/2010#
    3. Dim endDate As Date = #1/31/2010#
    4.  
    5. ' Prepare the event arguments:
    6. Dim e As New DateRangeEventArgs(startDate, endDate)
    7.  
    8. ' FormName here is a placeholder for your actual form that contains your MonthCalendar.
    9. Call FormName.MonthCalendar1_DateSelected(me, e)

  3. #3

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Re: how to call MonthCalendar1_DateSelected from another form

    thanks cicatrix

    I want the start and end date to be the current selected date of my month calendar. will try and figure it out now.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: how to call MonthCalendar1_DateSelected from another form

    How about using properties
    vb.net Code:
    1. Public ReadOnly Property StartDate() As String
    2.     Get
    3.         Return txtStartDate.Text
    4.     End Get
    5.  
    6. End Property
    7.  
    8. Public ReadOnly Property EndDate() As String
    9.     Get
    10.         Return txtEndDate.Text
    11.     End Get
    12.  
    13. End Property
    then call them from whereever
    Code:
    'form form2
    txtStartDate.Text = Form1.StartDate
    txtEndDate.Text = Form1.EndDate

  5. #5

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Re: how to call MonthCalendar1_DateSelected from another form

    thanks guys. problem has been resolved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width