?
Solved

CListCtrl not showing all sub items

Posted on 2000-04-12
7
Medium Priority
?
200 Views
Last Modified: 2013-11-20
I have a list control on a dialog.  I'm using the CListCtrlEx class from the VC++ samples.  When I add items to the list only a few of the sub items are added, even though the code to add them is in a loop, so the same code is used each time.  Any ideas why and how I can get round it?

Jim
0
Comment
Question by:ch52jb
[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
7 Comments
 
LVL 3

Expert Comment

by:shaig
ID: 2707511
Did you add all columns req?
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 2707530
Please post some code...
0
 

Author Comment

by:ch52jb
ID: 2707670
The code for the list control is

/////////////////////////////////////////////////////////////////////////////
// CListCtrlEx

BOOL CListCtrlEx::AddColumn(LPCTSTR strItem,int nItem,int nSubItem,int nMask,int nFmt)
{
      LV_COLUMN lvc;
      lvc.mask = nMask;
      lvc.fmt = nFmt;
      lvc.pszText = (LPTSTR) strItem;
      lvc.cx = GetStringWidth(lvc.pszText) + 15;
      if(nMask & LVCF_SUBITEM){
            if(nSubItem != -1)
                  lvc.iSubItem = nSubItem;
            else
                  lvc.iSubItem = nItem;
      }
      return InsertColumn(nItem,&lvc);
}

BOOL CListCtrlEx::AddItem(int nItem,int nSubItem,LPCTSTR strItem,int nImageIndex)
{
      LV_ITEM lvItem;
      lvItem.mask = LVIF_TEXT;
      lvItem.iItem = nItem;
      lvItem.iSubItem = nSubItem;
      lvItem.pszText = (LPTSTR) strItem;
      if(nImageIndex != -1){
            lvItem.mask |= LVIF_IMAGE;
            lvItem.iImage |= LVIF_IMAGE;
      }
      if(nSubItem == 0)
            return InsertItem(&lvItem);
      return SetItem(&lvItem);
}

I'm calling it using:

m_List.AddColumn("Word", 0);
m_List.AddColumn("Score", 1);

for(int nCount = 0; nCount < 10; ++nCount)
{
 m_List.AddItem(nCount, 0, MyString1);
 m_List.AddItem(nCount, 1, MyString2);
}
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Accepted Solution

by:
GregoryG earned 400 total points
ID: 2707874
According you code you should see 10
Row with one item and one subitem.
Like this:
"Word"      "Score"
MyString1   MyString2
.....................
MyString1   MyString2
If it what you see but not what you want you should change your code. Please explain what you want in that case.
In case that it is what you want but not what you see check if you list control is sorted. If so you should correct your code like this:
int index;
for(int nCount = 0; nCount < 0;++nCount)
{
 index = m_List.AddItem(nCount, 0, MyString1);
 m_List.AddItem(index, 1, MyString2);
}
Because if you have sorted ListCtrl item will be inserted not into nCount position and InsertItem(&lvItem); will return real row of inserted item.
As whole I'll recommend use code like above and you never need to worry if you have sorted List or not.
0
 
LVL 3

Expert Comment

by:shaig
ID: 2708055
What is the output?
Are whoule items missing? or just sum items?
0
 
LVL 3

Expert Comment

by:V_Bapat
ID: 2708173
>When I add items to the list only a few of the sub items are added...

Can you elaborate on that?
0
 

Author Comment

by:ch52jb
ID: 2708208
I had the list set to sort, hence my problems.  Cheers, enjoy the points!
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

801 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