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

x
?
Solved

CListCtrl not showing all sub items

Posted on 2000-04-12
7
Medium Priority
?
201 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
Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

656 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