Grid just populated with few rows, so there is an empty area below those rows.
Multiselection is enabled.
Grid has just been populated, so there are no selected rows.
If I click on the empty area below the rows, I get this exception:
System.Exception: Exception caught by
CurrentDomain.UnhandledException - type: System.NullReferenceException value:
System.NullReferenceException: Object reference not
set
to an instance of an
object
.<br> at
Telerik.WinControls.UI.GridRowBehavior.DoMultiFullRowSelect(GridCellElement
currentCell, Point currentLocation)<br> at
Telerik.WinControls.UI.GridRowBehavior.DoMouseSelection(GridCellElement
currentCell, Point currentLocation)<br> at
Telerik.WinControls.UI.GridRowBehavior.ProcessMouseSelection(Point
mousePosition, GridCellElement currentCell)<br> at
Telerik.WinControls.UI.GridRowBehavior.OnMouseMove(MouseEventArgs e)<br> at
Telerik.WinControls.UI.BaseGridBehavior.OnMouseMove(MouseEventArgs e)<br> at
Telerik.WinControls.UI.RadGridView.OnMouseMove(MouseEventArgs e)<br> at
System.Windows.Forms.Control.WmMouseMove(Message& m)<br> at
System.Windows.Forms.Control.WndProc(Message& m)<br> at
Telerik.WinControls.RadControl.WndProc(Message& m)
if I select a row, before clicking on the empty area, nothing happens.
I could preselect a row, just after populating. but I'd like to understand why this happens
6 Answers, 1 is accepted
I was not able to reproduce the observed behavior on my end. For convenience, I prepared a small sample, based on the information that you provided so far and attached it to this thread. Could you please check it and let me know how it differs from your real setup?
Could you please confirm that you are using the latest version of the suite as well.
I am looking forward to your reply.
Dimitar
Progress Telerik
thanks dimitar
Your sample works. I've modified it so now it crashes, and in the process, I've tracked it down to theme being the problem. in other words:
- without no themes applied, no errors
- with VisualStudio2012Light theme applied, it crashes
No, I'm not on the latest. I'm using 2015_2_728
Apparently I
I was able to reproduce the issue with the specified version. This is an old issue and it is fixed in R1 2016.
To work around it with the version that you are using you need a custom row behavior. Here is the code:
class
MyGridDataRowBehavior : GridDataRowBehavior
{
protected
override
bool
ProcessMouseSelection(Point mousePosition, GridCellElement currentCell)
{
var prop =
typeof
(GridRowBehavior).GetField(
"orderedRows"
, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(
this
);
if
(prop ==
null
)
{
return
false
;
}
return
base
.ProcessMouseSelection(mousePosition, currentCell);
}
}
Register the above behavior with the following code:
BaseGridBehavior gridBehavior = radGridView1.GridBehavior
as
BaseGridBehavior;
gridBehavior.UnregisterBehavior(
typeof
(GridViewDataRowInfo));
gridBehavior.RegisterBehavior(
typeof
(GridViewDataRowInfo),
new
MyGridDataRowBehavior());
I hope this will be useful. Let me know if you have additional questions.
Regards,
Dimitar
Progress Telerik
thanks Dimitar
unfortunately the issue is not fixed. it happens less often, but still happens. i've also tryed this, but still not solves
protected override bool ProcessMouseSelection(Point mousePosition, GridCellElement currentCell)
{
var prop = typeof(GridRowBehavior).GetField("orderedRows", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(this);
if (prop == null)
{
Console.WriteLine("MyGridDataRowBehavior prop was null");
return false;
}
var currentCellValue = currentCell == null ? "null" : (currentCell.Value == null ? ".Value is null" : currentCell.Value.ToString());
Console.WriteLine($"base.ProcessMouseSelection mousePosition={mousePosition.ToString()} currentCell:{currentCellValue}");
try
{
return base.ProcessMouseSelection(mousePosition, currentCell);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return false;
}
}
when it crashes, 'prop', 'mousePosition' and 'currentCell' are all valid
I have attached an updated version of the test project. Could you please try it and let me know if you still can reproduce the issue (I tried many times but there is no exception on my side).
If the objects are valid maybe this is another exception. Could you check if the StackTrace is the same?
I am looking forward to your reply.
Dimitar
Progress Telerik