-
July 21st, 2004, 10:05 AM
#1
have you even run into problem like this?
Just use a listctrl in my view, and when I insert item like this, the data won't be able to display multiple rows of data correctly
Code:
this->m_ListCtrl.InsertItem(i,name,0);
s.Format("%s",name);
this->m_ListCtrl.SetItemText(i,0,s);
there are several item block has no text displayed in the listctrl at all.
but if you change format line into
Code:
s.Format(" %s",name);
by adding an extra space in front of the %s, it will work. Wondering why...
-
July 21st, 2004, 10:26 AM
#2
It looks like your problem is in sorting style of your list control.
Either change this style to NONE (in resource editor)
or (the best way for you)
correct your code:
Code:
int iItem = this->m_ListCtrl.InsertItem(i,name,0);
if(iItem > -1)
{
s.Format("%s",name);
this->m_ListCtrl.SetItemText(iItem,0,s);
}
-
July 21st, 2004, 11:19 AM
#3
A few things:- Why are you using this-> when accessing m_ListCtrl? You don't need that, just write m_ListCtrl.
- Why are you using Format("%s") to assign a string to another? Just assign it with s = name. To add a blank, write s = " " + name;
- When adding an item with InsertItem(), you can specify an item index. However, this is just a request, it is not guaranteed that the item will be inserted at that position. That's why InsertItem() returns the actual item index, and you should use that in your call to SetItemText(), not your original index. Especially when the list control is sorted, the index will differ from the one you supplied, so I suspect that this is your actual problem.
-
July 21st, 2004, 06:36 PM
#4
habit from Java
I just thinking java when programming in VC, so that's why I like to use this pointer to avoid ambiguity.
no point using format , but I am just curious.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|