[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

CListCtrl ReportView Header

Posted on 2000-03-07
7
Medium Priority
?
272 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 40 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
Independent Software Vendors: 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

Independent Software Vendors: 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!

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…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

649 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