|
-
April 18th, 1999, 12:37 AM
#1
***ListCtrl.pszText = szItem as CString***
Hi,
I am making a program that uses CListView as its main view. I am using: lvi.pszText = szItem; to add text to the items I insert into it.
The computer will only let me use a char value for szItem, but I need it as a CString because all the values I want to pass to it are CString values!!!!
Are there any ways to make a ListView item text a CString value or to convert a CString to char????
Thanks ALOT!!!!!!!!!!!!!
-
April 18th, 1999, 04:01 AM
#2
Re: ***ListCtrl.pszText = szItem as CString***
Extract the string using the operator LPCTSTR of CString, and copy the same into pszText of lv_item s
structure.
Sample Code:
CString cItemText ;
// get the item text.
lstrcpy(ListCtrl.pszText, cItemText.opeartor LPCTSTR());
-
April 19th, 1999, 06:31 AM
#3
Re: ***ListCtrl.pszText = szItem as CString***
The easiest and best way is to do this
CString str = "your value";
for each Item you add you just call this
item.pszText = str.GetBuffer(0);
Hussam
-
April 19th, 1999, 07:07 AM
#4
Re: ***ListCtrl.pszText = szItem as CString***
Don't do what Srinath suggests and copy the string into the pszText of the lv_item(s), because the pszText expects the *address* of a string, and unless you have already initialized pszText to point to an allocated buffer in memory, your program will probably crash.
The GetBuffer() solution is better.
Dave
-
April 21st, 1999, 01:45 PM
#5
Re: ***ListCtrl.pszText = szItem as CString***
Hi,
I just do
CString text;
ListCtrl.pszText = (LPCSTR)text;
and it works.
Nath.
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
|