Need help with CListCtrl.SetItemText() 
Author Message
 Need help with CListCtrl.SetItemText()

I've got a strange situation, Maybe someone can help (?)
======================================
 m_List.InsertItem(0, "Primary");
 m_List.SetItemText(0,1,"Secondary");
 m_List.SetItemText(0,2,"444444");

 m_List.InsertItem(1, "More");
 m_List.SetItemText(1,1,"SecondMore");
 m_List.SetItemText(1,2,"444444");

My list will appear like:

Primary    |                            |                      |
More       |  SecondMore      |  444444        |

And if I add more items, only at the last one all sub-items are correct, and
in the previous items, only the Loftmost one.

Any Idea ??
======================================



Sun, 18 May 2003 03:00:00 GMT  
 Need help with CListCtrl.SetItemText()

Quote:

>I've got a strange situation, Maybe someone can help (?)
>======================================
> m_List.InsertItem(0, "Primary");
> m_List.SetItemText(0,1,"Secondary");
> m_List.SetItemText(0,2,"444444");
>Primary    |                            |                      |
>More       |  SecondMore      |  444444        |

>And if I add more items, only at the last one all sub-items are correct, and
>in the previous items, only the Loftmost one.

Is the list sorted? If so, the index you're using may not be correct, as
once the item is inserted, the order changes.

Try:

int index = m_List.InsertItem(0, "Primary");
m_List.SetItemText(index,1,"Secondary");
m_List.SetItemText(index,2,"444444");

--

 http://www.andyh.uklinux.net/space - disk usage analysis tool



Sun, 18 May 2003 03:00:00 GMT  
 Need help with CListCtrl.SetItemText()
On Wed, 29 Nov 2000 12:05:23 +0200, "Julie"


Quote:
>I've got a strange situation, Maybe someone can help (?)
>======================================
> m_List.InsertItem(0, "Primary");
> m_List.SetItemText(0,1,"Secondary");
> m_List.SetItemText(0,2,"444444");

You shouldn't assume that the index of the inserted item will
necessarily be 0, 1, etc.  This is safer:

int iItem = m_List.InserItem(0, "Primary");
BOOL bResult = m_List.SetItemText(iItem, 1, "Secondary");
bResult = m_List.SetItemText(iItem, 2, "444444");

Quote:
> m_List.InsertItem(1, "More");
> m_List.SetItemText(1,1,"SecondMore");
> m_List.SetItemText(1,2,"444444");

>My list will appear like:

>Primary    |                            |                      |
>More       |  SecondMore      |  444444        |

>And if I add more items, only at the last one all sub-items are correct, and
>in the previous items, only the Loftmost one.

Is the list sorted in any way?  That, combined with the error I
pointed out above, would account for this problem.

--
Chip Calvert - Celtic Wolf, Inc.
Software Design and Development, Project Management,
Technical Writing, Research
(703) 580-0210



Sun, 18 May 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. CListCtrl difference InsertItem() and SetItemText(0,...)

2. CListCtrl::SetItemText( ) problem

3. probelm with CListCtrl::SetItemText

4. When CListCtrl::SetItemText will not set the text

5. CListCtrl and SetItemText

6. CListCtrl difference InsertItem() and SetItemText(0,...)

7. CListCtrl.SetItemText()

8. When CListCtrl::SetItemText will not set the text

9. need help CListCtrl.SetDataItem() & CListCtrl.GetDataItem()

10. Help needed: ClistCtrl & Return Key

11. Help need filling ClistCtrl

12. CListCtrl and FindItem problem, need help please

 

 
Powered by phpBB® Forum Software