We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Not Highlighting Current Row after a Group Has Been Expanded or Header Clicked

Hi, I''m using the standard code in PrepareViewStyleInfo to hightlight the current row: // Work out if we''re query the stlye for the current cell bool isCurrentCellStyle = false; if (currentCell != null && currentCell.RowIndex == e.Inner.RowIndex && currentCell.ColIndex == e.Inner.ColIndex) { isCurrentCellStyle = true; } // currentCell.HasCurrentCellAt(e.Inner.RowIndex // Thsi tells us if we''re drawing for the samre row that the current cell is // Highlight the current row with SystemColors.Highlight if (currentCell != null && currentCell.RowIndex > grid.TableModel.Rows.HeaderCount && e.Inner.RowIndex > grid.TableModel.Rows.HeaderCount && e.Inner.ColIndex > grid.TableModel.Cols.HeaderCount && currentCell.HasCurrentCellAt(e.Inner.RowIndex) && ! isCurrentCellStyle) { e.Inner.Style.Interior = highlightRowBrush; e.Inner.Style.TextColor = SystemColors.HighlightText; } This all works fine. But I''ve noticed that collapsing or expanding a group will result in the current row not being highlighted - (FYI currentCell.IsActive is false) I''ve also noticed that if I click a col header (to sort) and that particular col is readonly it also doesn''t highlight the row as expected. Any clues? Thanks in advance Jason

8 Replies

AD Administrator Syncfusion Team October 21, 2004 01:57 PM

Does it work if you check for CurrentElement instead? private void gridGroupingControl1_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e) { GridTableCellStyleInfo style = (GridTableCellStyleInfo) e.Inner.Style; if (style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell || style.TableCellIdentity.TableCellType == GridTableCellType.AddNewRecordFieldCell) { Record r = style.TableCellIdentity.DisplayElement.ParentRecord; if (r.IsCurrent) { GridControlBase grid = e.TableControl; if (!grid.CurrentCell.HasCurrentCellAt(e.Inner.RowIndex, e.Inner.ColIndex)) { e.Inner.Style.BackColor = SystemColors.Highlight; e.Inner.Style.TextColor = SystemColors.HighlightText; } } } } Stefan


BW Brian Wright October 22, 2004 11:51 AM

No that does not appear to work. I am running into the same problem. I can use the PrepareViewStyleInfo event to highlight the row if is the current selection. However, whenever I click a group header it does not get highlighted. The row is still the current however because if I hit the down arrow then it moves to the next row and properly highlights it. Any ideas? >Does it work if you check for CurrentElement instead? > > > private void gridGroupingControl1_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e) > { > GridTableCellStyleInfo style = (GridTableCellStyleInfo) e.Inner.Style; > if (style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell > || style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell > || style.TableCellIdentity.TableCellType == GridTableCellType.AddNewRecordFieldCell) > { > Record r = style.TableCellIdentity.DisplayElement.ParentRecord; > if (r.IsCurrent) > { > GridControlBase grid = e.TableControl; > if (!grid.CurrentCell.HasCurrentCellAt(e.Inner.RowIndex, e.Inner.ColIndex)) > { > e.Inner.Style.BackColor = SystemColors.Highlight; > e.Inner.Style.TextColor = SystemColors.HighlightText; > } > } > } > } > > > >Stefan >


AD Administrator Syncfusion Team October 24, 2004 06:52 AM

Hi Brian, when you press the arrow key, the current cell uses some cached row and column properties as base for the navigation. That does not mean that there is an active current cell. Can you prepare a small sample (or modify our GroupCustomers example) to demonstrate the problem you have? Thanks, Stefan


JH Jason Hales October 25, 2004 03:13 AM

I''ve attached a sample c# app that I use to try out the features of the grid. Whenyou run the app, place a check against the following check boxes: "Apply Grouping" "Highlight Row" Now if you select any reocrd and then click any header you''ll find that the previous seleted record if not highlighted. As mention, pressing arrow key does highlight it - you can even click a header in which the current record doesn''t exist and again only get the row hightlighted after pressing an arrow key. Hope this helps. TIA Jason Grouping Grid Sample_6784.zip


AD Administrator Syncfusion Team October 25, 2004 04:17 PM

Here is your sample back. I modified it to use the technique shown in the sample in this thread http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=20768 to highlight the current row. Grouping Grid Sample_6784_5443.zip


AD Administrator Syncfusion Team December 10, 2004 04:38 AM

This all works great, thanks. One little problem though. 1. Highlight a row, eg row 2 2. Make some changes to the underlying data 3. Call syncGrid.TableControl.EndUpdate(true); 4. Click on a different row - the previous row (2) is still highlighted. 5. Click another row and row 2 is unhighlighted as expected I have hacked it to work by calling syncGrid.TableControl.CurrentCell.MoveLeft(); syncGrid.TableControl.CurrentCell.MoveRight(); before Endupdate - but is there a better way Thanks again Jason >Here is your sample back. I modified it to use the technique shown in the sample in this thread http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=20768 to highlight the current row. > >Grouping Grid Sample_6784_5443.zip > >


AD Administrator Syncfusion Team December 10, 2004 01:07 PM

Hi Jason, I am not exactly sure about the steps to reproduce in your sample. Do you have a test method in that sample that performs the steps below? Anyway, since you mention the problem is with changing data from outside, I guess the problem is that the ListChanged event resets your current record. Try handling the SourceListListChanged event. There you can specify e.ShouldResetCurrentRecord = false. Then the current record will not be reset. Stefan


AD Administrator Syncfusion Team December 12, 2004 05:30 AM

Jason, one more thing. This may be related. In the 3.0 samples check out the CustomCellTypes example. This sample has code for expanding records or groups without moving the current record. Stefan

Loader.
Live Chat Icon For mobile
Up arrow icon