I have a project with a Main Form (Control Panel) which launches a calendar (Class Library), I am trying to add a new appointment to my calendar, cant get appointment to appear in calendar when calendar is opened, only shows if I close then reopen.
Everything works as it should, just cant add appointment when calendar is opened, can someone point me in the right direction
Adding Appointment
Everything works as it should, just cant add appointment when calendar is opened, can someone point me in the right direction
Code:
Private m_calendar As frmSharedCalendar = New frmSharedCalendar
Public Sub New(mycalendar As DevComponents.DotNetBar.Schedule.CalendarView)
m_calendar.CalendarView1 = mycalendar
InitializeComponent()
End Sub
Sub New()
InitializeComponent
' TODO: Complete member initialization
End SubAdding Appointment
Code:
Dim appointment As New Appointment()
'add appointment to calendar
appointment.Subject = cmbPurpose.Text
If chkAllDayEvent.Checked = True Then
cmbStartTime.ResetText()
cmbStartTime.Enabled = False
cmbEndTime.ResetText()
cmbEndTime.Enabled = False
appointment.StartTime = DateTime.Today
appointment.EndTime = appointment.StartTime.AddDays(1)
ElseIf chkAllDayEvent.Checked = False Then
cmbStartTime.Enabled = True
cmbEndTime.Enabled = True
appointment.StartTime = Date.Now 'CDate(cmbStartDate.Value & " " & cmbStartTime.Value.ToString("H:mm:ss"))
appointment.EndTime = Date.Now.AddHours(3) 'CDate(cmbEndDate.Value & " " & cmbEndTime.Value.ToString("H:mm:ss"))
End If
If cmbShowTimeAs.SelectedIndex = 0 Then
appointment.TimeMarkedAs = appointment.TimerMarkerFree
End If
If cmbShowTimeAs.SelectedIndex = 1 Then
appointment.TimeMarkedAs = appointment.TimerMarkerTentative
End If
If cmbShowTimeAs.SelectedIndex = 2 Then
appointment.TimeMarkedAs = appointment.TimerMarkerBusy
End If
If cmbShowTimeAs.SelectedIndex = 3 Then
appointment.TimeMarkedAs = appointment.TimerMarkerOutOfOffice
End If
appointment.OwnerKey = cmbFor.Text
' Add appointment to the model
' frmSharedCalendar.mymodel.Appointments.Add(appointment)
m_calendar.CalendarView1.CalendarModel.Appointments.Add(appointment)
'_SharedCalendar.CalendarView1.CalendarModel.Appointments.Add(appointment)
'frmSharedCalendar.CalendarView1.CalendarModel.Appointments.Add(appointment)
' Make appointment visible in current view
m_calendar.CalendarView1.EnsureVisible(appointment)
m_calendar.Refresh()