Changing MultiViewRows or MultiViewCols causes error

4 posts, 0 answers
  1. Peter
    Peter avatar
    14 posts
    Member since:
    Apr 2009

    Posted 02 Mar 2011 Link to this post

    When I change either the MultiViewRows or MultiViewCols property of a calendar, it gives the error:

    Object Reference not set to an instance of an object

    This always seems to happen if I increase the number of Rows or Columns but also seems to happen occasionally if I decrease them.

    The rows/col change was initially donein the SizeChanged event but to ensure that was not the reason for the problem, I set up a test with a button that just changes the Rows and Cols from 5 and 2 to 4 and 3 and the error happens every time.

    Is anybody else experiencing this and is their a workaround that anybody can give me.

    Thanks in advance
  2. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 02 Mar 2011 Link to this post

    Hello Peter,

    Sorry, i could not reproduce this issue, can you please test it in the following test project and let me know:

    using System;
    using System.Drawing;
    using System.Windows.Forms;
    using Telerik.WinControls.UI;
     
    public partial class Form1 : Form
    {
        private RadCalendar radCalendar1;
        public Form1()
        {
            InitializeComponent();
            this.Size = new Size(800, 600);
     
            this.Controls.Add(radCalendar1 = new RadCalendar());
            radCalendar1.Dock = DockStyle.Fill;
            radCalendar1.AllowMultipleView = true;
     
            var addRow = new RadButton();
            addRow.Text = "Add Rows";
            addRow.Click += new EventHandler(addRow_Click);
            this.Controls.Add(addRow);
            addRow.Dock = DockStyle.Bottom;
     
            var addColumn = new RadButton();
            addColumn.Text = "Add Columns";
            addColumn.Click += new EventHandler(addColumn_Click);
            this.Controls.Add(addColumn);
            addColumn.Dock = DockStyle.Bottom;
        }
     
        void addColumn_Click(object sender, EventArgs e)
        {
            radCalendar1.MultiViewColumns++;
        }
     
        void addRow_Click(object sender, EventArgs e)
        {
            radCalendar1.MultiViewRows++;
        }
    }

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
    Telerik WinForms MVP
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Peter
    Peter avatar
    14 posts
    Member since:
    Apr 2009

    Posted 02 Mar 2011 Link to this post

    Hi Emanuel

    I tried your code example and it worked with no problem, however my code is a lot more complex and after many hours of trying different things, it looks like the problem occurs when the FocusedDate is set to a date that is not currently being displayed. I have added the FocusedDate line to your code and I always get the error the second time I press the add row or column button.

    public partial class Form1 : Form
    {
        private RadCalendar radCalendar1;
        public Form1()
        {
            InitializeComponent();
            this.Size = new Size(800, 600);
            this.Controls.Add(radCalendar1 = new RadCalendar());
            radCalendar1.Dock = DockStyle.Fill;
            radCalendar1.AllowMultipleView = true;
            radCalendar1.MultiViewColumns = 2;
            radCalendar1.MultiViewRows = 2;
            //
            // Set the focused date to 5 days ago
            //
            radCalendar1.FocusedDate = DateTime.Today.AddDays(-5);
            var addRow = new RadButton();
            addRow.Text = "Add Rows";
            addRow.Click += new EventHandler(addRow_Click);
            this.Controls.Add(addRow);
            addRow.Dock = DockStyle.Bottom;
            var addColumn = new RadButton();
            addColumn.Text = "Add Columns";
            addColumn.Click += new EventHandler(addColumn_Click);
            this.Controls.Add(addColumn);
            addColumn.Dock = DockStyle.Bottom;
        }
        void addColumn_Click(object sender, EventArgs e)
        {
            radCalendar1.MultiViewColumns++;
        }
        void addRow_Click(object sender, EventArgs e)
        {
            radCalendar1.MultiViewRows++;
        }
    }

    The stack trace indicates the problem is located as follows

    at Telerik.WinControls.UI.CalendarMultiMonthViewTableElement.Recreate()
    at Telerik.WinControls.UI.MultiMonthViewElement.SetProperty(PropertyChangedEventArgs e)
    at Telerik.WinControls.UI.MonthViewElement.view_PropertyChanged(Object sender, PropertyChangedEventArgs e)
    at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
    at Telerik.WinControls.UI.CalendarView.OnNotifyPropertyChanged(PropertyChangedEventArgs e)
    at Telerik.WinControls.UI.CalendarView.OnNotifyPropertyChanged(String propertyName)
    at Telerik.WinControls.UI.CalendarView.Calendar_PropertyChanged(Object sender, PropertyChangedEventArgs e)
    at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
    at Telerik.WinControls.RadControl.OnNotifyPropertyChanged(PropertyChangedEventArgs e)
    at Telerik.WinControls.UI.RadCalendar.OnNotifyPropertyChanged(PropertyChangedEventArgs e)
    at Telerik.WinControls.RadControl.OnNotifyPropertyChanged(String propertyName)
    at Telerik.WinControls.UI.RadCalendar.set_MultiViewRows(Int32 value)
    <....My Project Details....>

    Thanks

    Peter
  5. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 07 Mar 2011 Link to this post

    Hello Peter,

    Thank you for the report.

    I managed to reproduce the described issue. It will be resolved in the upcoming major release. Your Telerik points have been updated for the feedback.

    If you have other questions, feel free to contact us.

    Greetings,
    Dobry Zranchev
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top