Solved

CListCtrl ReportView Header

Posted on 2000-03-07
7
263 Views
Last Modified: 2008-02-01
How do I retrieve the header text in each column from a CListCtrl?  I can retrieve all of the item text but not the header.  I tried redirecting the header but still cannot find a call that will return the text in each column.

CHeaderCtrl* pCtrl = m_List.GetHeaderCtrl();


Thanks,

Janet
0
Comment
Question by:jaiken
  • 4
  • 3
7 Comments
 
LVL 4

Expert Comment

by:captainkirk
Comment Utility
I haven't tested this, but try something like this:

HDITEM hi;
CString csText = _T("");
int nPos = 0;

CHeaderCtrl* pCtrl = m_refListCtrl.GetHeaderCtrl();

for (int nIndex = 0; nIndex < pCtrl->GetItemCount(); nIndex++)
{
     pCtrl->GetItem(nPos, &hi);
     csText = hi.pszText;
} // end for
0
 

Author Comment

by:jaiken
Comment Utility
That gives an assertion error but thanks for trying.
0
 
LVL 4

Accepted Solution

by:
captainkirk earned 10 total points
Comment Utility
Janet - here's the working version:

char buf[128];
LVCOLUMN lvc;
lvc.mask = LVCF_TEXT;
lvc.pszText = buf;
lvc.cchTextMax = 128;

CString csText = _T("");

CHeaderCtrl* pCtrl = m_refListCtrl.GetHeaderCtrl();
      
int nCount = m_refListCtrl.GetItemCount();

for (int nIndex = 0; nIndex < nCount; nIndex++)
{
     m_refListCtrl.GetColumn(nIndex, &lvc);
     csText = lvc.pszText;
} // end for


Hope that helps...
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:jaiken
Comment Utility
Thank you so much Captain.
0
 

Author Comment

by:jaiken
Comment Utility
Oh, the only thing that I believe must be changed is the nCount must be equal to the number of columns, not the number of items (= #rows).  
0
 
LVL 4

Expert Comment

by:captainkirk
Comment Utility
right you are...
0
 

Author Comment

by:jaiken
Comment Utility
Thank you very much.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now