Click here to Skip to main content
15,867,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a list dynamically, with create, now I Want to insert items inside but it doesn't work, I tried with insert item
C++
<pre>m_pBtnList = new CMyListUt;
			//bRes =(ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, cellRect1, this, 1);
			m_pBtnList->Create(WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_REPORT,	cellRect1, this, 1);
			m_pBtnList->EnableScrollBar(true);

			int					nI, nRowMater;
			nRowMater = 0;
			int					dim, nWidth;
			DWORD				dwStyles;
			RECT				rList;
			CString				strCol;

		
			dim = cellRect1.right - cellRect.left;

									// aggiunge colonna "Prog."
		
			m_pBtnList->InsertColumn(0, _T(""), LVCFMT_RIGHT, dim, -1);

			

			LVCOLUMN lvCol;
			lvCol.mask = LVCF_TEXT | LVCF_WIDTH;
			lvCol.pszText = L"Column Header Text";
			m_pBtnList->InsertColumn(0, &lvCol);




			LVITEM item;
			item.mask = LVIF_TEXT;
			item.pszText = _T("Column Text");
			item.iItem = 0;      // Item number
			item.iSubItem = 0;         // Sub item number (column number)
			m_pBtnList->InsertItem(&item);
			
			dwStyles = LVS_EX_TRACKSELECT | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES;
			m_pBtnList->SetExtendedStyle(GetExtendedStyle() | dwStyles);










What I have tried:

if I use insert item and then setItem i see only the first element, and the cstring in my list is not complet, I want to insert the word 'Configuration',but in list I see when I compile, 'Config...' and then I don't see the second element that I have added
Posted
Updated 26-Nov-20 21:22pm
v2
Comments
Richard MacCutchan 26-Nov-20 15:57pm    
Please use the Improve question link above and add the code that shows what you are doing.
Member 14594285 27-Nov-20 2:37am    
ok, done

1 solution

C++
LVCOLUMN lvCol;
lvCol.mask = LVCF_TEXT | LVCF_WIDTH;
lvCol.pszText = L"Column Header Text";
m_pBtnList->InsertColumn(0, &lvCol);

You specify here that the cx (width) field is valid, but you have not set its value. So it will be whatever value happens to exist in that cell on the stack.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900