UltraWinGrid v9.2. The following code borrowed from these forums loops through the columns collection and sets the header check state to checked or unchecked. The problem is this only happens (graphically) on visible (on screen, not hidden) columns, however if you scroll right and view all of the columns, this method then checks or unchecks all columns whether they are visible on screen or not. In other words, after the grid loads for the first time the off screen columns will not receive the visibly checked appearance until you have scrolled and viewed them on screen at least one time and run the method again. The code, however knows that each column is checked regardless of appearing unchecked, so this is a wierd graphics thing. Adding a myGrid.Refresh() and/or myGrid.Update() did not help. Is there a way to have the checked appearance visible without having to first view the columns?
private void myGrid_AfterHeaderCheckStateChanged(object sender, AfterHeaderCheckStateChangedEventArgs e){ UltraGridColumn c = e.Column; CheckState newCheckState = c.GetHeaderCheckedState(e.Rows);
switch (newCheckState) { case CheckState.Checked: foreach (UltraGridColumn siblingColumn in c.Band.Columns) { if (siblingColumn == c) continue;
siblingColumn.SetHeaderCheckedState(e.Rows, true); }
break; case CheckState.Unchecked: foreach (UltraGridColumn siblingColumn in c.Band.Columns) { if (siblingColumn == c) continue;
siblingColumn.SetHeaderCheckedState(e.Rows, false); } break; default: break; }}
Hello,
Let me see if I understand your situation correctly. If there are columns which have never been scrolled into view, and you check one of the header checkboxes, the checkboxes for the out of view columns are do not appear to be in sync with the underlying values once the columns are scrolled into view.
Is the code which is supposed to check the out of view columns being triggered by the user clicking on a visible header checkbox, programmatically calling SetHeaderCheckedState(), or by some other method?
What are the HeaderCheckBoxSynchronization set to for all the columns?
If you are calling SetHeaderCheckedState() on your own, what are you passing in for the Rows parameter?
When the HeaderCheckBoxSynchronization resolves to Band, the CheckState value for the column is stored on the Band. However, when it resolves to RowsCollection or None, the value is stored on the provided RowsCollection. When using RowsCollection or None, if null is passed to the SetHeaderCheckState(), the value cannot be set.
What build of NetAdvantage 2009 Volume 2 are you using? It may be beneficial to installed the latest service release for the volume to see if this behavior is already addressed.
How to get the latest service release - Infragistics Community
Note that the code you provided has been modified from my original posting which will cause all the column checkboxes to be checked/unchecked no matter which one is clicked. Additionally, since AfterHeaderCheckStateChanged event fires for each checkstate that changes, you will loop through the column numerous times unintentionally. If you are not going to only perform the processing for a single column, you should use a recursion flag to prevent the extraneous processing.
Thanks,
Chris
Hi Chris,
Correct. The code I posted loops through the columns collection and checks \ unchecks each column header's checkbox. The out of view columns do appear to be visually checked, but their checked property is truly checked.
Yes, this event is triggered by the user clicking on the first visible column's checkbox, the only column with no header text.
You only need to scroll right and view all of the columns for the same method to visual check each checkbox, now regardless of they are out of view. I just do not want to have to tell the users to scroll fully right and back left before using this "check all" functionality. :)
HeaderCheckBoxSynchronization.Default. I did not set this property, but tried .Band and .RowsCollection and the issue I was having went away, but left me with other errors and the unwanted appearance of having all checkboxes start in an intermediate checked state.
Runtime version v2.0.50727, Version 9.2.20092.1003. We own up to the latest 11.x build, but unfortunately are very slow to migrate. This may change very soon!
Thanks. The method I posted isn't exactly what I have. My thought was to remove custom noise before posting. Here is the untouched code...
private void gridBuySell_AfterHeaderCheckStateChanged(object sender, AfterHeaderCheckStateChangedEventArgs e){ UltraGridColumn c = e.Column; CheckState newCheckState = c.GetHeaderCheckedState(e.Rows);
switch (newCheckState) { case CheckState.Checked: if (c.Header.Caption == string.Empty) { //ColumnsCollection cols = c.Band.Columns.All;
foreach (UltraGridColumn siblingColumn in c.Band.Columns) { if (siblingColumn == c) continue;
siblingColumn.SetHeaderCheckedState(e.Rows, true); _selPorts.Add(c.Header.Caption); } } else { _selPorts.Add(c.Header.Caption); } _selPorts.Sort(); break; case CheckState.Indeterminate: break; case CheckState.Unchecked: if (c.Header.Caption == string.Empty) { //ColumnsCollection cols = c.Band.Columns;
siblingColumn.SetHeaderCheckedState(e.Rows, false); } _selPorts.Clear(); //clear them all } else { _selPorts.Remove(c.Header.Caption); } _selPorts.Sort(); break; default: break; }}