Solved

CListCtrl ReportView Header

Posted on 2000-03-07
7
266 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
ID: 2592067
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
ID: 2592174
That gives an assertion error but thanks for trying.
0
 
LVL 4

Accepted Solution

by:
captainkirk earned 10 total points
ID: 2592268
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:jaiken
ID: 2592548
Thank you so much Captain.
0
 

Author Comment

by:jaiken
ID: 2592587
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
ID: 2592605
right you are...
0
 

Author Comment

by:jaiken
ID: 2592614
Thank you very much.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

685 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