using SetItemText to print a CString 
Author Message
 using SetItemText to print a CString

Hello, is there any way to print out a CString in another
column of a listbox using SetItemText?
I am using a listbox to print out names, etc from a
database and InsertItem will print fine, but only in the
first column, and if I pass a CString to SetItemText
nothing is printed.

my code:

lbptr->InsertItem(i, rs.GetString("sTaskTitle"));
lbptr->SetItemText(i, 1, rs.GetString("sRunning"));
lbptr->SetItemText(i, 2, rs.GetString("sComplete"));

where rs is CRecordset object, and GetString returns a
string value from the db.
T.I.A
MWR



Wed, 14 Jan 2004 01:56:57 GMT  
 using SetItemText to print a CString
If you are using InsertItem and SetItemText, you are using a list control
not a list box.  Try replacing rs.GetString("sRunning") and
rs.GetString("sComplete") with an actual string of characters to see if that
has any effect.  Set a breakpoint on the first call to SetItemText() and
step into the CListCtrl code.  Are any assertions firing or error codes
being returned?


Quote:
> Hello, is there any way to print out a CString in another
> column of a listbox using SetItemText?
> I am using a listbox to print out names, etc from a
> database and InsertItem will print fine, but only in the
> first column, and if I pass a CString to SetItemText
> nothing is printed.

> my code:

> lbptr->InsertItem(i, rs.GetString("sTaskTitle"));
> lbptr->SetItemText(i, 1, rs.GetString("sRunning"));
> lbptr->SetItemText(i, 2, rs.GetString("sComplete"));

> where rs is CRecordset object, and GetString returns a
> string value from the db.
> T.I.A
> MWR



Wed, 14 Jan 2004 04:18:01 GMT  
 using SetItemText to print a CString

Quote:
>Hello, is there any way to print out a CString in another
>column of a listbox using SetItemText?

You'd need to create a complete tab delimited string and use
SetTabStops to set the position of the columns.

You might do better using a list control in report/detail mode. That
would give you more control, and a header for the columns too.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Wed, 14 Jan 2004 05:52:12 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Using CString functionality without CString variable/cast operator

2. Using CString functionality without CString variable/cast operator

3. Printing a report using MFC (Unhandled exception error when print previewing)

4. Printing a report using MFC (Unhandled exception error when print previewing)

5. Seeking word wrap CString printing algorithm

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

7. List Control LVS_SORTASCENDING and SetItemText

8. CListCtrl::SetItemText( ) problem

9. probelm with CListCtrl::SetItemText

10. Print out CString

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

12. SetItemText Not Working In CListView::OnUpdate

 

 
Powered by phpBB® Forum Software