Skip rows in Report Control that are not editable |
Post Reply |
Author | |
orca
Newbie Joined: 05 November 2009 Status: Offline Points: 1 |
Post Options
Thanks(0)
Posted: 06 November 2009 at 12:32pm |
I have a report control that contains three columns and 100+ rows. Some of the rows are considered category headers (Category 1, Category 2, etc.) while others are calculated. Category headers and calculated rows are not editable. All other rows allow for user input in the second and third column (the first column is a description of the row). All of this has been implemented by another programmer and is working correctly.
I've been tasked with adding a bit of keyboard navigation for the grid such that when a user hits the up or down arrow key, the focus will skip any non-editable rows, jumping immediately to the next editable row in the grid in either direction. I should add here that I have very little experience in using these controls. What I've come up with is to override the OnFocusChanging event in our derived report control class. In that event I've added logic to do the navigation described above and it works, at least as far as skipping the non-editable rows are concerned. The problem is that when I use that code to skip the non-editable rows I can no longer edit the editable rows. It selects them as if they were editable but I can't actually type in them anymore. So the navigation works, but I've somehow killed the editing. Here's my navigation code, for better or worse: BOOL CDerivedListReportCtrl::OnFocusChanging(CXTPReportRow* pNewRow, CXTPReportColumn* pNewCol) { BOOL rc = FALSE; if (pNewRow) { int iNewRowIndex = pNewRow->GetIndex(); CXTPReportRows* pRows = GetRows(); ASSERT(pRows); int iRowCount = pRows->GetCount(); int iFocusedIndex = 0; // Find the currently focused row for (int i = 0; i < pRows->GetCount(); i++) { CXTPReportRow* pRow = pRows->GetAt(i); if (pRow->IsFocused()) { iFocusedIndex = i; break; } } if (pNewRow->GetRecord()->GetItem(1)->IsEditable()) { rc = TRUE; } else { //if iFocusedIndex < iNewRowIndex then we're moving down, otherwise we're moving up if (iFocusedIndex < iNewRowIndex) { do { iFocusedIndex++; if (iFocusedIndex < iRowCount) { if (pRows->GetAt(iFocusedIndex)->GetRecord()->GetItem(1)->IsEditable()) { break; } } } while (iFocusedIndex < iRowCount); } else { do { iFocusedIndex--; if (iFocusedIndex > 0) { if (pRows->GetAt(iFocusedIndex)->GetRecord()->GetItem(1)->IsEditable()) { break; } } } while (iFocusedIndex > 0); } if (iFocusedIndex < 1) { iFocusedIndex = 1; } SetFocusedRow(pRows->GetAt(iFocusedIndex)); } } return rc; } If I comment that code out and just return TRUE I can edit the rows again but the non-editable rows are no longer skipped (obviously). If I enable the above code, navigation works but I can't edit any of the editable rows (which are just CXTPReportItemText objects). Any help would be greatly appreciated. Thank you in advance. |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |