Select/Focus a single row? |
Post Reply |
Author | |
craig
Groupie Joined: 11 August 2005 Location: United States Status: Offline Points: 44 |
Post Options
Thanks(0)
Posted: 19 April 2006 at 1:04pm |
I'm a bit stumped on how I can select and set focus to a CXTPReportRecord that I just added? Any help would be appreciated (I can submit a support ticket if that is preferable)
In my OnInitDialog method I am adding all of my records to the report control. As I add them, I am inspecting them to determine which row should be the one that is selected (Single selection). I store the pointer to this record and then after calling Populate() (which as I understand it will sort my records) I use the following code to set the stored record as selected/focused. It is selecting/focusing a different record than the one I cached the pointer to though. // pSelectedRecord is the record I just added to the // report control that I want to set as selected and // with focus CXTPReportSelectedRows* pSelectedRows = m_wndSrsList.GetSelectedRows(); if (pSelectedRows != NULL) { int nRow = pSelectedRecord->GetIndex(); CXTPReportRows* pRows = m_wndSrsList.GetRows(); CXTPReportRow* pRow = pRows->GetAt(nRow); m_wndSrsList.SetFocusedRow(pRow); if (pRow != NULL) { pSelectedRows->Clear(); pSelectedRows->Add(pRow); } } |
|
rmercer
Groupie Joined: 22 February 2006 Status: Offline Points: 34 |
Post Options
Thanks(0)
|
Here's how I do it in my code, I also use groups so I have to expand the group too: m_ctlCategories.Populate(); if (p_record_selected != NULL){ p_rows = m_ctlCategories.GetRows(); if (p_rows != NULL){ p_row = p_rows->Find(p_record_selected); if (p_row != NULL){ p_row->GetParentRow()->SetExpa nded(TRUE); m_ctlCategories.SetFocusedRow(p_row); } }
|
|
craig
Groupie Joined: 11 August 2005 Location: United States Status: Offline Points: 44 |
Post Options
Thanks(0)
|
Thank you that worked.
It actually appears that I was adding the record I needed to select after calling populate which is why my original code was failing. Your code works too though, and I appreciate you taking the time to answer my question. In fact, I didn't discover my bug until I tried applying your code. --Craig |
|
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 |