Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
exception while ungrouping a grid with GroupLayout
posted

Hi,

We ran into an issue with UltraGrid (WinForms Infragistics v.18.2).

When dragging a column header to group by that column and then dragging it back to the grid for ungrouping, we get the next exception:

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at Infragistics.Win.UltraWinGrid.UltraGridBase.ColumnChooser_DragDropHelper(Point mouseLocInClient, Boolean performDrop, CurrentCursor& cursorToDisplay)
at Infragistics.Win.UltraWinGrid.UltraGridBase.ColumnChooser_OnDragMove(Point mouseLocInClient, CurrentCursor& cursorToDisplay)
at Infragistics.Win.UltraWinGrid.UltraGrid.DragMoveHelper(Point pointInControlCoords, Boolean isMultiSelectColumnChooser)
at Infragistics.Win.UltraWinGrid.GroupByButtonUIElement.OnMouseMove(MouseEventArgs e)
at Infragistics.Win.ControlUIElementBase.ProcessMouseMoveHelper(Object sender, MouseEventArgs e)
at Infragistics.Win.ControlUIElementBase.ProcessMouseMove(Object sender, MouseEventArgs e)
at Infragistics.Win.Utilities.ProcessEvent(Control control, ProcessEvent eventToProcess, EventArgs e)
at Infragistics.Win.UltraControlBase.OnMouseMove(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseMove(Message& m)
at System.Windows.Forms.Control.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)

Repro steps:

private class GridData
{
public string Col1 { get; set; }

public int Col2 { get; set; }

public int Col3 { get; set; }
}

public Form1()
{
InitializeComponent();
ultraGrid1.DataSource = new List<GridData>() { new GridData() { Col1 = "T1", Col2 = 10, Col3 = 20 }, new GridData() { Col1 = "T2", Col2 = 30, Col3 = 40 } };
}

private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{

// Store the layout and root band in member variables for easy reference.
UltraGridLayout layout = e.Layout;
UltraGridBand rootBand = layout.Bands[0];

// Set the RowLayoutStyle to allow groups in RowLayout mode.
rootBand.RowLayoutStyle = RowLayoutStyle.GroupLayout;

// Add a couple of groups.
UltraGridGroup group1 = rootBand.Groups.Add("Dummy");
UltraGridGroup group2 = rootBand.Groups.Add("Group 1");

// Assign each column to a group.
rootBand.Columns["Col1"].RowLayoutColumnInfo.ParentGroup = group1;
rootBand.Columns["Col2"].RowLayoutColumnInfo.ParentGroup = group2;
rootBand.Columns["Col3"].RowLayoutColumnInfo.ParentGroup = group2;

}

The exception only appears when the groups are expanded and we reach a dataRow while dragging the grouped column header back.

Is there a workaround to get rid of this exception?