I have a RadScheduler with ActiveViewType = Day and RadScheduler1.GroupType = GroupType.Resource which my resources are my Employee.
I wrote this code to create an appointment, but it does not work and my RadScheduler does not show the appointment:
Private Sub NewAppointment(ByVal StartDateTime As Date, ByVal EndDateTime As Date, ByVal EmployeeID As Integer)
Dim duration As Long = DateAndTime.DateDiff(DateInterval.Hour, StartDateTime, EndDateTime)
Dim apt As New Appointment()
apt.Start = StartDateTime
apt.End = StartDateTime.AddHours(duration)
apt.Summary = "Summary Test"
apt.ResourceId =
New EventId(EmployeeID)
'RadScheduler1.Appointments.Add(apt)
RadScheduler1.ActiveView.Appointments.Add(apt)
End Sub
What did I wrong?
I am looking forward to hearin from you as soon as possible.
Thank you in advanced.
Kian
12 Answers, 1 is accepted
Thank you for writing.
Generally, it is not a good practise to add an appointment directly to the view. You should add your appointments to the Appointments collection of RadScheduler
Dim
StartDateTime
As
DateTime =
Me
.radScheduler1.ActiveView.StartDate
Dim
apt
As
New
Appointment()
apt.Start = StartDateTime
apt.[
End
] = StartDateTime.Add(
New
TimeSpan(1, 0, 0))
apt.Summary =
"Summary Test"
apt.ResourceId =
New
EventId(2)
radScheduler1.Appointments.Add(apt)
You will not see the added appointment only if the resources collection of the scheduler does not contain the resource id.
If you have other questions, feel free to write back.
Kind regards,
Dobry Zranchev
the Telerik team
Thank you
If you want to convert some code from vb to c# or from c# to vb, you can always use the Code Converter provided by telerik.
Following is the code that Dobry posted, converted to C#:
DateTime StartDateTime =
this
.radScheduler1.ActiveView.StartDate;
Appointment apt =
new
Appointment();
apt.Start = StartDateTime;
apt.End = StartDateTime.Add(
new
TimeSpan(1, 0, 0));
apt.Summary =
"Summary Test"
;
apt.ResourceId =
new
EventId(2);
radScheduler1.Appointments.Add(apt);
Best Regards,
Emanuel Varga
'Telerik.Web.UI.AppointmentCollection.Friend Sub Add(apt As Telerik.Web.UI.Appointment)'
is not accessible in this context because it is 'Friend'.
Has this functionality changed since your response? It appears that this example worked previously. If not, what am I doing wrong? I'm trying to use this code inside the TimeSlotContextMenuItemClicking event handler to automatically create an appointment without the user having to use the dialog box to name it.
Thanks!
Brad
RadScheduler1.Appointments.Add(apt)
I should use this:
RadScheduler1.InsertAppointment(apt)
This seems to work in this case.
Thanks!
Brad
Telerik.Web.UI.Appointment meetingAppointment = new Telerik.Web.UI.Appointment();
meetingAppointment.Subject = "Test";
meetingAppointment.Start = DateTime.Now;
meetingAppointment.End = DateTime.Now;
RadScheduler1.InsertAppointment(meetingAppointment);
TimeSpan ts = new TimeSpan(0, 12, 0, 0);
meetingAppointment.Subject = "Test2";
meetingAppointment.Start = DateTime.Now + ts;
meetingAppointment.End = DateTime.Now + ts;
RadScheduler1.InsertAppointment(meetingAppointment);
Thank you for writing.
This forum concerns RadScheduler for WinForms and your questions seems to concern the RadScheduler for ASP.NET AJAX. Please address your question to the appropriate forums: http://www.telerik.com/community/forums/aspnet-ajax/scheduler.aspx.
Kind regards,
Stefan
the Telerik team
Please help me. I want to add appointment with code. Please write to me how can i do this. (with header and all thing to do this).thanks
You simply have to create an instance of the Appointment class, populate the desired properties of the object and add it to the Appointments collection of RadScheduler. Here is a sample explaining this: http://www.telerik.com/help/winforms/scheduler-appointments-and-dialogs-working-with-appointments.html.
I hope this helps.
Regards,
Stefan
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Dim StartDateTime As DateTime = Me.RadScheduler1.ActiveView.StartDate
Dim apt As New Appointment()
apt.Start = StartDateTime
apt.[End] = StartDateTime.Add(New TimeSpan(23, 59, 59))
apt.Summary = "Client #0001"
apt.Description = "Counselor Jeff"
apt.ResourceId = New EventId(2)
RadScheduler1.Appointments.Add(apt)
apt.Start = StartDateTime
apt.[End] = StartDateTime.Add(New TimeSpan(23, 59, 59))
apt.Summary = "Client #0002"
apt.Description = "Counselor Shanti"
apt.ResourceId = New EventId(2)
RadScheduler1.Appointments.Add(apt)
The issue here comes from the fact that you are only changing the properties of the very same object you have created. If you want to use the same variable, you need to reinstantiate it with "New":
Dim
StartDateTime
As
DateTime =
Me
.RadScheduler1.ActiveView.StartDate
Dim
apt
As
New
Appointment()
apt.Start = StartDateTime
apt.[
End
] = StartDateTime.Add(
New
TimeSpan(23, 59, 59))
apt.Summary =
"Client #0001"
apt.Description =
"Counselor Jeff"
apt.ResourceId =
New
EventId(2)
RadScheduler1.Appointments.Add(apt)
Dim
apt
As
New
Appointment()
apt.Start = StartDateTime
apt.[
End
] = StartDateTime.Add(
New
TimeSpan(23, 59, 59))
apt.Summary =
"Client #0002"
apt.Description =
"Counselor Shanti"
apt.ResourceId =
New
EventId(2)
RadScheduler1.Appointments.Add(apt)
I hope this helps.
Regards,
Stefan
Telerik
Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.