Menu

How to Add Items/Events to Calendar

Mark
2016-01-05
2024-03-04
  • Mark

    Mark - 2016-01-05

    I went over the control's original article, but can't figure out how to add events to the calendar. The methods mentioned in the original article aren't showing up in intellisense and I don't see anything in intellisense that looks like it would add items - something like Calendar1.items.add() or whatever.

    I'm reading the events from an XML file. I'm iterating through the events in the XML data and want to add them to the Calendar as I loop through each of the event nodes.

     
  • Chris Bray

    Chris Bray - 2016-02-23

    Something like this?:

    // Create some calendar items

    var items = new List<>CalendarItem();

    items.Add(new CalendarItem(calendar1, DateTime.Now, DateTime.Now.AddMinutes(30), "First Appointment");
    items.Add(new CalendarItem(calendar1, DateTime.Now.AddDays(1), DateTime.Now.AddDays(1).AddMinutes(30), "First Appointment");

    // Add the items to the calendar
    calendar1.Items.Clear();
    foreach (CalendarItem item in items)
    {
    if (calendar1.viewIntersects(item))
    {
    calendar1.Items.Add(item);
    }
    }

    Chris Bray
    
     
  • Gary Morris

    Gary Morris - 2020-05-27

    I just double click on the time I want to add something, and then start typing. It adds an item for me.

     
  • Mark Moore

    Mark Moore - 2024-03-04

    Anything I do, I keep getting NULL REFERENCE....here is my code

                List<CalendarItem>
                   items = new List<CalendarItem>();
    
                CalendarItem i = new CalendarItem(calendar,
                   new DateTime(2024, 3, 23), new DateTime(2014, 3, 31, 23, 59, 59), "Vacation 1");
    
                items.Add(i);
    
                calendar.Items.Clear();
    
                foreach (CalendarItem item in items)
                {
                   if (calendar.ViewIntersects(item))
                   {
                      calendar.Items.Add(item);
                   }
                }
    
                calendar.Items.AddRange(items);
    
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.