Ctrl List Box
-
Hi, i have a value CString p = flocation; i want to store it in a list box in the 2 col lvi.mask = LVIF_TEXT; lvi.iItem = 0; lvi.iSubItem = 1; lvi.pszText = "value here"; m_INDEX_INFO_LIST.SetItem(&lvi); can anyone tell how to do that ?? i tryed with lvi.pszText = p but its giveing error, can anyone help me with this. Regards, Vinay Charan. -- modified at 6:27 Tuesday 16th May, 2006
-
Hi, i have a value CString p = flocation; i want to store it in a list box in the 2 col lvi.mask = LVIF_TEXT; lvi.iItem = 0; lvi.iSubItem = 1; lvi.pszText = "value here"; m_INDEX_INFO_LIST.SetItem(&lvi); can anyone tell how to do that ?? i tryed with lvi.pszText = p but its giveing error, can anyone help me with this. Regards, Vinay Charan. -- modified at 6:27 Tuesday 16th May, 2006
CListBox or CListCtrl?_**
**_
whitesky
-
CListBox or CListCtrl?_**
**_
whitesky
-
Hey vinay, There is no such method like SetItem() for CListBox but For CListCtrl it is avilable.. Knock out 'T' from CAN'T , You 'CAN' if you think you 'CAN' :cool:
-
Hey vinay, There is no such method like SetItem() for CListBox but For CListCtrl it is avilable.. Knock out 'T' from CAN'T , You 'CAN' if you think you 'CAN' :cool:
-
Hi, i have a value CString p = flocation; i want to store it in a list box in the 2 col lvi.mask = LVIF_TEXT; lvi.iItem = 0; lvi.iSubItem = 1; lvi.pszText = "value here"; m_INDEX_INFO_LIST.SetItem(&lvi); can anyone tell how to do that ?? i tryed with lvi.pszText = p but its giveing error, can anyone help me with this. Regards, Vinay Charan. -- modified at 6:27 Tuesday 16th May, 2006
of course CListCtrl if you get error you can use (0)if you use vs2005 use lvi.pszText = LPTSTR(p ); ---------------------------------------------- (1) if vs2003 then use lvc.pszText = CA2T(strItem); --------------------------------------------- (2) LPCTSTR m_str; m_str="test"; lvi.pszText = (LPTSTR)m_str; -------------------------- (3) TCHAR m_str[20]; m_str[0]='\0'; strcat(m_str,"test"); lvi.pszText = (LPTSTR)m_str; -------------------------- (4) LPTSTR m_str; m_str=(LPTSTR)LocalAlloc(LPTR,256); strcat(m_str,"test"); lvi.pszText = m_str; ---------------------------_**
**_
whitesky
-- modified at 7:10 Tuesday 16th May, 2006
-
for CListBox use AddString or InsertString_**
**_
whitesky
-
here is another simple code in which i added two columns and added the data using InsertItem and SetItemText API's
m_test.InsertColumn(0,"hi",LVCFMT_LEFT,100);
m_test.InsertColumn(1,"bye",LVCFMT_LEFT,100);m_test.InsertItem(index,"");
m_test.SetItemText(index,0,"HI");
m_test.SetItemText(index,1,"Bye");where index is Listcontrol Item Index where you can add the Item from 0 to n Knock out 'T' from CAN'T , You 'CAN' if you think you 'CAN' :cool:
-
of course CListCtrl if you get error you can use (0)if you use vs2005 use lvi.pszText = LPTSTR(p ); ---------------------------------------------- (1) if vs2003 then use lvc.pszText = CA2T(strItem); --------------------------------------------- (2) LPCTSTR m_str; m_str="test"; lvi.pszText = (LPTSTR)m_str; -------------------------- (3) TCHAR m_str[20]; m_str[0]='\0'; strcat(m_str,"test"); lvi.pszText = (LPTSTR)m_str; -------------------------- (4) LPTSTR m_str; m_str=(LPTSTR)LocalAlloc(LPTR,256); strcat(m_str,"test"); lvi.pszText = m_str; ---------------------------_**
**_
whitesky
-- modified at 7:10 Tuesday 16th May, 2006
-
of course CListCtrl if you get error you can use (0)if you use vs2005 use lvi.pszText = LPTSTR(p ); ---------------------------------------------- (1) if vs2003 then use lvc.pszText = CA2T(strItem); --------------------------------------------- (2) LPCTSTR m_str; m_str="test"; lvi.pszText = (LPTSTR)m_str; -------------------------- (3) TCHAR m_str[20]; m_str[0]='\0'; strcat(m_str,"test"); lvi.pszText = (LPTSTR)m_str; -------------------------- (4) LPTSTR m_str; m_str=(LPTSTR)LocalAlloc(LPTR,256); strcat(m_str,"test"); lvi.pszText = m_str; ---------------------------_**
**_
whitesky
-- modified at 7:10 Tuesday 16th May, 2006
Hey, nice information Knock out 'T' from CAN'T , You 'CAN' if you think you 'CAN' :cool:
-
Hey, nice information Knock out 'T' from CAN'T , You 'CAN' if you think you 'CAN' :cool:
Thanks:)_**
**_
whitesky
-
Thanks:)_**
**_
whitesky
Hi WhiteSky, one more dout i want to store the date & time in the 4th col how to do that ?? how to access the current time and date and store it in a variable and pass it to col 6th ?? lvi.mask = LVIF_TEXT; lvi.iItem = 6; lvi.iSubItem = 1; lvi.pszText = "16/05/06 4:59 PM"; // In this format only ?? m_INDEX_INFO_LIST.SetItem(&lvi);
-
Hi WhiteSky, one more dout i want to store the date & time in the 4th col how to do that ?? how to access the current time and date and store it in a variable and pass it to col 6th ?? lvi.mask = LVIF_TEXT; lvi.iItem = 6; lvi.iSubItem = 1; lvi.pszText = "16/05/06 4:59 PM"; // In this format only ?? m_INDEX_INFO_LIST.SetItem(&lvi);
-
-
Hi, I am not getting the solution can u tell me COleDateTime dateTest; dateTest = COleDateTime::GetCurrentTime(); lvi.mask = LVIF_TEXT; lvi.iItem = 6; lvi.iSubItem = 1; lvi.pszText = "16/05/06 4:30 PM"; m_INDEX_INFO_LIST.SetItem(&lvi);
CString str; SYSTEMTIME st; GetLocalTime(&st); str.Format("%d:%d:%d:",st.wHour,st.wMinute,st.wSecond);_**
**_
whitesky
-
CString str; SYSTEMTIME st; GetLocalTime(&st); str.Format("%d:%d:%d:",st.wHour,st.wMinute,st.wSecond);_**
**_
whitesky
CString str; SYSTEMTIME st; GetLocalTime(&st); str.Format("%d:%d:%d:",st.wHour,st.wMinute,st.wSecond); lvi.mask = LVIF_TEXT; lvi.iItem = 6; lvi.iSubItem = 1; lvi.pszText = (LPTSTR)str; m_INDEX_INFO_LIST.SetItem(&lvi); Can u please also tell how to pass it to list box ? i tryed the above code its giveing error...
-
CString str; SYSTEMTIME st; GetLocalTime(&st); str.Format("%d:%d:%d:",st.wHour,st.wMinute,st.wSecond); lvi.mask = LVIF_TEXT; lvi.iItem = 6; lvi.iSubItem = 1; lvi.pszText = (LPTSTR)str; m_INDEX_INFO_LIST.SetItem(&lvi); Can u please also tell how to pass it to list box ? i tryed the above code its giveing error...
for insert string to CListBox you need to AddString or InsertString CListBox m_List; m_List.InsertString or m_List.AddString_**
**_
whitesky
-
CString str; SYSTEMTIME st; GetLocalTime(&st); str.Format("%d:%d:%d:",st.wHour,st.wMinute,st.wSecond); lvi.mask = LVIF_TEXT; lvi.iItem = 6; lvi.iSubItem = 1; lvi.pszText = (LPTSTR)str; m_INDEX_INFO_LIST.SetItem(&lvi); Can u please also tell how to pass it to list box ? i tryed the above code its giveing error...
vinaycool wrote:
...its giveing error...
Are we supposed to guess what the error is?
"The largest fire starts but with the smallest spark." - David Crow
-
Hi, i have a value CString p = flocation; i want to store it in a list box in the 2 col lvi.mask = LVIF_TEXT; lvi.iItem = 0; lvi.iSubItem = 1; lvi.pszText = "value here"; m_INDEX_INFO_LIST.SetItem(&lvi); can anyone tell how to do that ?? i tryed with lvi.pszText = p but its giveing error, can anyone help me with this. Regards, Vinay Charan. -- modified at 6:27 Tuesday 16th May, 2006
vinaycool wrote:
lvi.pszText = "value here";
Try:
lvi.pszText = (LPTSTR) (LPCTSTR) p;
vinaycool wrote:
...but its giveing error...
So what's the error?
"The largest fire starts but with the smallest spark." - David Crow
-
vinaycool wrote:
lvi.pszText = "value here";
Try:
lvi.pszText = (LPTSTR) (LPCTSTR) p;
vinaycool wrote:
...but its giveing error...
So what's the error?
"The largest fire starts but with the smallest spark." - David Crow
hi, I had used lvi.pszText = (LPTSTR)str; i was getting below error error C2440: 'type cast' : cannot convert from 'class CString' to 'char *' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called Error executing cl.exe. Creating browse info file... lvi.pszText = (LPTSTR) (LPCTSTR) p; after using the above statment its working proeprly Thanks a lot ....:)