Hi,
I have implemented the 'Check All Header Cell' as shown in this KB article http://www.telerik.com/support/kb/winforms/gridview/add-check-uncheck-all-check-box-in-the-header-cell.aspx.
This works really well in most scenarios but I have run into a small bump in the road. The problem is that I have two grids that are linked in a cascading style. The purpose of this is to fill grid 2 with all of the contacts relating to the selected person or people in grid 1. Again this is all working perfectly for single or multiple selections using the normal check boxes in the rows.
I am hooking in to the ValueChanged event and then checking the cell type to determine if it is a single or check all operation. I set a processing flag to avoid multiple runs of the population code. The flag is reset in the DataBindingComplete event.
The problem I am getting is that the databinding is so fast that the flag is reset almost instantly. The 'Check All' code from the KB article works by setting each checkbox to checked in a loop. This is firing the ValueChanged event and running the Grid 2 population code over and over again resulting in a lengthy delay (30 secs +) when the header cell is clicked.
I need a way to notify my app that the 'Check All' operation has finished (that is all of the check boxes have had their state changed and there are no other ValueChanged events to be raised). The following method from CheckBoxHeaderCell.cs is where I would expect see an event being raised from, but I cannot figure out a way to hook such an event from my app or make it bubble up via the grid.
I add the column to my grid using the following code, I have checked the events available to 'checkColumn' and there is nothing suitable that I can see.
Can you please let me know if there is a way to raise an event from this custom header cell that can be hooked into by my app.
Many Thanks
Chris
I have implemented the 'Check All Header Cell' as shown in this KB article http://www.telerik.com/support/kb/winforms/gridview/add-check-uncheck-all-check-box-in-the-header-cell.aspx.
This works really well in most scenarios but I have run into a small bump in the road. The problem is that I have two grids that are linked in a cascading style. The purpose of this is to fill grid 2 with all of the contacts relating to the selected person or people in grid 1. Again this is all working perfectly for single or multiple selections using the normal check boxes in the rows.
I am hooking in to the ValueChanged event and then checking the cell type to determine if it is a single or check all operation. I set a processing flag to avoid multiple runs of the population code. The flag is reset in the DataBindingComplete event.
private void PupilGrid_ValueChanged(object sender, EventArgs e) { //set a processing flag as if the select all checkbox is used this //event fires for every checkbox in the column! if (_populatingParentGrid) return; _populatingParentGrid = true; if (sender.GetType() == typeof(GridViewCellInfo)) { //this means the select all box has been checked RefreshParentGrid(true); } else if (sender.GetType() == typeof(RadCheckBoxEditor)) { //single box checked RefreshParentGrid(false); } }private void ParentGrid_DataBindingComplete(object sender, GridViewBindingCompleteEventArgs e) { //reset processing flag _populatingParentGrid = false; //PupilGrid.Enabled = true; }The problem I am getting is that the databinding is so fast that the flag is reset almost instantly. The 'Check All' code from the KB article works by setting each checkbox to checked in a loop. This is firing the ValueChanged event and running the Grid 2 population code over and over again resulting in a lengthy delay (30 secs +) when the header cell is clicked.
I need a way to notify my app that the 'Check All' operation has finished (that is all of the check boxes have had their state changed and there are no other ValueChanged events to be raised). The following method from CheckBoxHeaderCell.cs is where I would expect see an event being raised from, but I cannot figure out a way to hook such an event from my app or make it bubble up via the grid.
private void checkbox_ToggleStateChanged(object sender, StateChangedEventArgs args) { if (suspendProcessingToggleStateChanged) return; bool valueState = false; if (args.ToggleState == ToggleState.On) { valueState = true; } GridViewElement.EditorManager.EndEdit(); TableElement.BeginUpdate(); foreach (GridViewRowInfo t in ViewInfo.Rows) { t.Cells[ColumnIndex].Value = valueState; } TableElement.EndUpdate(false); TableElement.Update(GridUINotifyAction.DataChanged); //Need to raise an event here to say that the processing has finished }I add the column to my grid using the following code, I have checked the events available to 'checkColumn' and there is nothing suitable that I can see.
private void AddCheckColumn() { //Telerik code - see above for link var checkColumn = new CustomCheckBoxColumn {Name = "Select", HeaderText = "All", ReadOnly = false}; //No suitable events found here PupilGrid.Columns.Insert(0, checkColumn); var checkColumn2 = new CustomCheckBoxColumn {Name = "Select", HeaderText = "All", ReadOnly = false}; ParentGrid.Columns.Insert(0, checkColumn2); }Can you please let me know if there is a way to raise an event from this custom header cell that can be hooked into by my app.
Many Thanks
Chris