Completed
Last Updated: 10 Sep 2015 12:24 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 06 Aug 2015 08:54
Category: GridView
Type: Bug Report
1
FIX. RadGridView - NullReferenceException after mouse down over the close button of a group item and the MultiSelect property is set to true
To reproduce:
public Form1()
{
    InitializeComponent();
    DataTable dt = new DataTable();
    dt.Columns.Add(new DataColumn("Id", typeof(int)));
    dt.Columns.Add(new DataColumn("Name", typeof(string)));
    
    for (int i = 0; i < 50; i++)
    {
        dt.Rows.Add(i, "Item" + i);
    }
    radGridView1.DataSource = dt; 
  
    radGridView1.MasterTemplate.MultiSelect = true;
}

1. Load a grid with enough rows to make scrolling necessary to see the bottom row.
2. Drag a column header into the group area.
3. Move the vertical scroll bar down. It doesn't matter if you scroll all the way to the end or just barely move the vertical scroll bar, as long as it isn't all the way to the top.
4. Put the mouse on the "X" of the group descriptor. Hold the left mouse button and move the mouse.

Workaround: use custom row behavior:

            BaseGridBehavior gridBehavior = rgvTest.GridBehavior as BaseGridBehavior;
            gridBehavior.UnregisterBehavior(typeof(GridViewDataRowInfo));
            gridBehavior.RegisterBehavior(typeof(GridViewDataRowInfo), new CustomGridDataRowBehavior());

public class CustomGridDataRowBehavior : GridDataRowBehavior
{
    public CustomGridDataRowBehavior()
    {
        typeof(GridRowBehavior).GetField("orderedRows", System.Reflection.BindingFlags.NonPublic |
                                                        System.Reflection.BindingFlags.Instance).SetValue(this, new List<GridViewRowInfo>()) ;
    }

    public override bool OnMouseUp(MouseEventArgs e)
    {
        bool result = base.OnMouseUp(e);              
        typeof(GridRowBehavior).GetField("orderedRows", System.Reflection.BindingFlags.NonPublic |
                                                        System.Reflection.BindingFlags.Instance).SetValue(this, new List<GridViewRowInfo>()) ;
        return result;  
    }
}
0 comments