Print Page | Close Window

Select an event in the calender

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Calendar
Forum Description: Topics Related to Codejock Calendar
URL: http://forum.codejock.com/forum_posts.asp?TID=9680
Printed Date: 07 October 2024 at 9:33am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Select an event in the calender
Posted By: paul_ont
Subject: Select an event in the calender
Date Posted: 24 February 2008 at 12:23pm
Is there any way programmatically select an event in the calender, highlighting the event the same way as it would if you manually selected the event in the control?



Replies:
Posted By: dentor
Date Posted: 24 February 2008 at 1:03pm
Hello,
 
You can use SelectViewEvent Method to select or unselect an event.
 


Posted By: paul_ont
Date Posted: 24 February 2008 at 7:43pm
Thanks..  still can't figure out how to get the selectviewevent to work.. Can anyone post an example using the selectviewevent selecting an event by its ID. 


Posted By: dentor
Date Posted: 25 February 2008 at 3:16am
For the SelectViewEvent method, we must specify a ViewEvent and not an Event, so we must retrieve the ViewEvent in the ActiveView of the Calendar.
 
If we suppose to have the Event display on the calendar, and you get the day and the id property of the event, this sub find it on the ActiveView and select it:  
 
Sub SelectThisEvent(FindDt As Date, FindId As Long)
Dim ViewEvt As CalendarViewEvent, i As Long, Ndx As Long
    With Calendar
      Ndx = -1
      For i = 0 To .ActiveView.DaysCount - 1
        If .ActiveView(i).Date = DateValue(FindDt) Then
            Ndx = i
            Exit For
        End If
      Next
 
      If Ndx > -1 Then
        For Each ViewEvt In .ActiveView(Ndx)
            If FindId = ViewEvt.Event.Id Then
                .ActiveView.SelectViewEvent ViewEvt, True
            End If
        Next
      End If
    End With
End Sub
 


Posted By: paul_ont
Date Posted: 28 February 2008 at 5:59pm
Thanks for the help..  That worked..


Posted By: ericl
Date Posted: 29 February 2008 at 3:51am

Very nice !

Where did you find in the help file that you can give an index to Calendar.ActiveView ?

In the 11.2.2 calendarcontrol help file i see :
Public Property ActiveView() As CalendarView

So i can't imagine we give an index to this method ?!

Thanks for your help
eric l.



Posted By: dwise
Date Posted: 18 March 2008 at 4:04am
Small addition, another way to select an event by it's key:
 
Private Sub SelectEventInView(ByRef prmCalendar As XtremeCalendarControl.CalendarControl, prmAgendaId As Long)
   
    Dim objViewGroup As XtremeCalendarControl.CalendarViewGroup
    Dim objViewEvent As XtremeCalendarControl.CalendarViewEvent
   
    For Each objViewGroup In prmCalendar.ActiveView(0).ViewGroups
        For Each objViewEvent In objViewGroup.ViewEvents
            If objViewEvent.Event.id = prmAgendaId Then
                objViewEvent.Selected = True
            End If
        Next
    Next
   
End Sub
 
Note: apparantly this only works if the view is set to week or day view.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net