This is a migrated thread and some comments may be shown as answers.

Changing MultiViewRows or MultiViewCols causes error

3 Answers 34 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 02 Mar 2011, 07:43 AM
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

3 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 02 Mar 2011, 12:27 PM
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
0
Peter
Top achievements
Rank 1
answered on 03 Mar 2011, 02:29 AM
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
0
Dobry Zranchev
Telerik team
answered on 07 Mar 2011, 02:44 PM
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!
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Peter
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Peter
Top achievements
Rank 1
Dobry Zranchev
Telerik team
Share this question
or