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

Upgrade to Q2 2012 sp1

6 Answers 103 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Pittco Management
Top achievements
Rank 1
Pittco Management asked on 14 Sep 2012, 12:39 PM
I have just recently upgraded a winform .net solution to the Q2 2012 sp1 version.  I am now receive this error on many different gridviews on many different forms.  I cannot reproduce the error on every machine, or in every instance.  But it is happening with high frequency.  Anyone have any ideas on this?

System.NullReferenceException: Object reference not set to an instance of an object.
at Telerik.WinControls.UI.CellAccessibleObject.owner_CellBeginEdit(Object sender, GridViewCellCancelEventArgs e)
at Telerik.WinControls.UI.GridViewCellCancelEventHandler.Invoke(Object sender, GridViewCellCancelEventArgs e)
at Telerik.WinControls.UI.RadGridView.OnCellBeginEdit(Object sender, GridViewCellCancelEventArgs e)
at Telerik.WinControls.UI.EventDispatcher.RaiseEvent[T](Object eventKey, Object sender, T args)
at Telerik.WinControls.UI.GridViewEditManager.BeginEdit()
at Telerik.WinControls.UI.GridRowBehavior.OnMouseUpLeft(MouseEventArgs e)
at Telerik.WinControls.UI.GridRowBehavior.OnMouseUp(MouseEventArgs e)
at Telerik.WinControls.UI.BaseGridBehavior.OnMouseUp(MouseEventArgs e)
at Telerik.WinControls.UI.RadGridView.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at Telerik.WinControls.RadControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)   at Telerik.WinControls.UI.CellAccessibleObject.owner_CellBeginEdit(Object sender, GridViewCellCancelEventArgs e)
at Telerik.WinControls.UI.GridViewCellCancelEventHandler.Invoke(Object sender, GridViewCellCancelEventArgs e)
at Telerik.WinControls.UI.RadGridView.OnCellBeginEdit(Object sender, GridViewCellCancelEventArgs e)
at Telerik.WinControls.UI.EventDispatcher.RaiseEvent[T](Object eventKey, Object sender, T args)
at Telerik.WinControls.UI.GridViewEditManager.BeginEdit()
at Telerik.WinControls.UI.GridRowBehavior.OnMouseUpLeft(MouseEventArgs e)
at Telerik.WinControls.UI.GridRowBehavior.OnMouseUp(MouseEventArgs e)
at Telerik.WinControls.UI.BaseGridBehavior.OnMouseUp(MouseEventArgs e)
at Telerik.WinControls.UI.RadGridView.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at Telerik.WinControls.RadControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

6 Answers, 1 is accepted

Sort by
0
Don
Top achievements
Rank 1
answered on 14 Sep 2012, 08:41 PM
From what we've seen where I work this is caused by the grid events firing before the grid is instantiated. The only workaround we've been able to come up with is to create a flag variable that bypasses the firing of events until after the grid is instantiated. We flip the flag after the grid has been filled so that any events that fire will have a grid to fire upon, so to speak.
0
Pittco Management
Top achievements
Rank 1
answered on 14 Sep 2012, 09:30 PM
I've seen that in the past as well.  In this case it is a gridview that has been loaded.  I have added a GridViewCheckBoxColumn so that you can perform operations on multiple rows at once (like delete).  The error occurs when right at the moment you click the check box on most rows.  It seems to be somewhat correlated to whether the column/row already had focus before you click the box.  But again, it only happens on certain machines.  On my development machine, I've never once seen the error.

This is the code I use to add the column after I have set the datasource to the gridview.

GridViewCheckBoxColumn remove = new GridViewCheckBoxColumn();
remove.DataType = typeof(int);
remove.FieldName = "remove";
remove.HeaderText = " ";
remove.ReadOnly = false;
ticketItems.MasterTemplate.Columns.Add(remove);


So in this case, it isn't because the gridview isn't instantiated.

Any other ideas?  Thanks for your thoughts on this.
0
Don
Top achievements
Rank 1
answered on 14 Sep 2012, 09:43 PM
What happens if you set the data type of the remove column to boolean instead of int?
0
Pittco Management
Top achievements
Rank 1
answered on 15 Sep 2012, 02:07 AM
Great question.  I couldn't figure out why they had that specified as int.  That was from this example. http://www.telerik.com/help/winforms/gridview-columns-gridviewcheckboxcolumn.html 

Before I found this example I didn't specify a type, and I can only assume that bool is the default.  But I'll need to test explicitly specifying bool.  I'll get the results tomorrow, and report back.  I doubt it will have an impact.

Anyone from Telerik?  This is a serious issue we are having causing close to 100 errors a day in a production environment.  The ONLY change that took place with this release was an upgrade to the latest Telerik.  Not exactly a great story to tell, and hard for me to explain to our clients.

I'm going to try to create a very simple project with just this error, that I can attach to a ticket, but again, it's so hard to debug because it only happens on certain machines...
0
Pittco Management
Top achievements
Rank 1
answered on 15 Sep 2012, 02:42 AM
I can only attach a file that is 2 MB?  This project couldn't be any smaller.  It is a single form with two grids.  Should I open a support ticket?

Here is the source.  I created a zip with this whole project, but I can't attach because it is 2.8 mb.  It has a single form with 2 grids, named "grid" and "grid2".  grid2 was strait from the toolbox.  grid was styled a bit for my application.  I wanted to confirm, that there wasn't any design elements that were causing these exceptions.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls.UI;


namespace TestGridView
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}


private void Form1_Load(object sender, EventArgs e)
{
loadgrid(grid);
loadgrid(grid2);
}
public void loadgrid(RadGridView grid)
{
grid.DataSource = null;
grid.AutoGenerateColumns = false;
if (grid.MasterTemplate.Columns.Count == 0)
{
GridViewCheckBoxColumn remove = new GridViewCheckBoxColumn();
remove.DataType = typeof(bool);
remove.FieldName = "remove";
remove.HeaderText = " ";
remove.ReadOnly = false;
grid.MasterTemplate.Columns.Add(remove);
grid.MasterTemplate.Columns.Add("Product", "Product", "Product");
grid.MasterTemplate.Columns.Add("Color", "Color", "Color");
grid.MasterTemplate.Columns.Add("Size", "Size", "Size");
grid.MasterTemplate.Columns.Add("PriceDetails", "Price", "PriceDetails");
grid.MasterTemplate.Columns.Add("Details", "Details", "Details");


grid.MasterTemplate.Columns["PriceDetails"].TextAlignment = ContentAlignment.MiddleRight;
grid.MasterTemplate.Columns["Product"].ReadOnly =
grid.MasterTemplate.Columns["Size"].ReadOnly =
grid.MasterTemplate.Columns["Color"].ReadOnly =
grid.MasterTemplate.Columns["Details"].ReadOnly =
grid.MasterTemplate.Columns["PriceDetails"].ReadOnly = true;
}


List<CustomItem> list = new List<CustomItem>();
list.Add(new CustomItem("test"));
list.Add(new CustomItem("test 2"));
list.Add(new CustomItem("test 3"));
grid.DataSource = list;
grid.BestFitColumns();
}
}
public class CustomItem
{
public CustomItem(string name)
{
Product = name;
Color = "blue";
Size = "2";
PriceDetails = "$9.99";
Price = 9.99m;
Details += "taxed";
}
public string Product { get; set; }
public string Color { get; set; }
public string Size { get; set; }
public string PriceDetails { get; set; }
public decimal Price { get; set; }
public string Details { get; set; }
}
}

0
Peter
Telerik team
answered on 17 Sep 2012, 02:00 PM
Hi all,

Pittco, I will post here my answer from your other thread:

This is an issue in the accessibility implementation of the grid which was introduced with the latest release. I have logged it in our Public Issue Tracking System and we will address it in the next official release. Here you can find the PITS item - the fix will be available in the next release. 

For the time being, you can workaround this issue by disabling the accessibility implementation of RadGridView. To achieve this, you should use the following derived class:
public class MyGridView : RadGridView
{
    protected override AccessibleObject CreateAccessibilityInstance()
    {
        return new Control.ControlAccessibleObject(this);
    }  
 
    public override string ThemeClassName
    {
        get
        {
            return typeof(RadGridView).FullName;
        }
        set
        {
            base.ThemeClassName = value;
        }
    }
}

Note that this functionality is only active when there is a running process which has requested the accessibility object of RadGridView. This can be screen reading software like Microsoft Narrator, UI automation or inspection tool or some other software that has similar functionality. You should not get the exception if nothing has requested the accessibility object of RadGridView.

Feel free to ask if you have any additional questions.

Regards,
Peter
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Pittco Management
Top achievements
Rank 1
Answers by
Don
Top achievements
Rank 1
Pittco Management
Top achievements
Rank 1
Peter
Telerik team
Share this question
or