Solved

CListCtrl ReportView Header

Posted on 2000-03-07
7
265 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 

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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

809 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