Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - InitialSelectionEnable not working
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

InitialSelectionEnable not working

 Post Reply Post Reply
Author
Message
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post Topic: InitialSelectionEnable not working
    Posted: 15 February 2009 at 11:50pm
Hi

I am setting InitialSelectionEnable(FALSE) on my report control.

however if there is nothing selected, and I click in a column header to sort, it selects a random row all by itself, and doesn't send any notification.

Adrien
Back to Top
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post Posted: 16 February 2009 at 12:05am
I hacked the report control to fix it.

void CXTPReportControl::ReSortRows()
{
     if (IsVirtualMode())
     {
          Populate();
          return;
     }

     // are there any selected rows?
     BOOL bRowsSelected = GetSelectedRows()->GetCount() != 0;

     SortTree(m_pPlainTree);

     CXTPReportRecord* pFocusedRecord = GetFocusedRow() ? GetFocusedRow()->GetRecord() : NULL;

     m_pRows->Clear();
     m_arrScreenRows.Clear(FALSE);

     for (int nGroupRow = 0; nGroupRow < m_pPlainTree->GetCount(); nGroupRow++)
     {
          CXTPReportRow* pRow = m_pPlainTree->GetAt(nGroupRow);
          InsertRow(m_pRows->GetCount(), pRow);
          pRow->m_nChildIndex = nGroupRow;
          ASSERT(pRow->m_pParentRows == m_pPlainTree);
     }

     //-----------------------------------------------------------------------
     m_nFocusedRow = -1;
     // Update indexes on virtual rows
     int nRowCount = m_pRows->GetCount();
     for (int nRowIndex = 0; nRowIndex < nRowCount; nRowIndex++)
     {
          CXTPReportRow* pRow = m_pRows->GetAt(nRowIndex);
          if (pRow)
          {
               pRow->SetIndex(nRowIndex);
               pRow->m_bVisible = TRUE;

               if (pFocusedRecord && pRow->GetRecord() == pFocusedRecord)
               {
                    m_nFocusedRow = pRow->GetIndex();
                    if (IsSelectionEnabled() && bRowsSelected)
                         m_pSelectedRows->Select(pRow);
               }
          }
     }

     AdjustIndentation();
     AdjustLayout();

     RedrawControl();
}

Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 16 February 2009 at 1:03am

Good - I check you contribution and with small modifications use it in our source (Release 13.1). Thanks.

void CXTPReportControl::ReSortRows()
{
   
....... 

   BOOL bRowsSelected = m_bInitialSelectionEnable;

   if (GetSelectedRows()!= NULL)
   {
      if (GetSelectedRows()->GetCount() > 0)
         bRowsSelected = TRUE;
   }

   .......
}
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.