Posted 27 January 2020, 2:21 am EST
Hi there everyone,
Lately my company have been updating our ComponentOne Studio for WinForms version in our Softwares, and one behavior that used to work in one of our C1FlexGrid, doesn’t work anymore.
The main flow was: clicking in multiple rows in the C1FlexGrid and then clicking in a CellButton of a selected row, we have a call to a BeforeSelChange before the CellButton event:
/// <summary>
/// After using CTRL to select multiple rows in grid (Exams)
/// Click in MPP buttons doesn't change the current selection
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void fgExams_BeforeSelChange(object sender, [b]C1.Win.C1FlexGrid.RangeEventArgs e[/b])
{
// Cast flex grid to our MultiSelectFlexGrid (a C1FlexGrid with selection overrides)
MultiSelectFlexGrid grd = sender as MultiSelectFlexGrid;
if (grd == null) return;
if (grd.SelectedCells.Count > 0)
{
// The new selection should be of one specific row and one specific column (cell with a cellbutton)
if (e.NewRange.c1 != e.NewRange.c2 || e.NewRange.r1 != e.NewRange.r2)
return;
int iSelectedRow = e.NewRange.r1;
int iSelectedCol = e.NewRange.c1;
// Se linha selecionada estava na seleção anterior, e existe mais de uma linha selecionada
if (grd.SelectedRows.Contains(iSelectedRow) && grd.SelectedRows.Count > 1)
{
// Check if the click is on the "MPP" column, if it is, maintains the selection cancelling the SelChange EventArgs
if (grd.Cols[iSelectedCol].Name.Equals("MPP"))
e.Cancel = true;
}
}
}
The thing is that, after this BeforeSelChange event, the callstack triggers the CellButtonClick event with a RowColEventArgs, and the difference is that when cancelling the event in BeforeSelChange it is now cancelling also the call to this CellButtonClick event.
When I removed the e.Cancel, the CellButtonClick is triggered correctly but that goes back to the original problem which led to the implementation of the BeforeSelChange that is losing the selection when clicking in a CellButton of a already selected cell.
I want to know if have anything changed in regard of the event callstack or the manipulation of eventargs objects in event calls, or if anyone have an idea about what happened or how we could solve this…
Thanks in Advance
Specifications:
.NET Framework version: 4.7.2
Before Update
C1 Studio for WinForms version: 4.0.20151.49
After Update
C1 Studio for WinForms version: 4.0.20193.393.