Click here to Skip to main content
15,882,209 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello!
C#
List.Create(WS_CHILD | WS_VISIBLE | LVS_REPORT /*| LVS_SINGLESEL*/ | LVS_EX_SUBITEMIMAGES | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | /*WS_BORDER |*/ WS_TABSTOP, CRect(0, 0, 0, 0), this, IDC_LIST);
m_pImg = new CImageList;
m_pImg->Create (16, 16, ILC_MASK, 8, 8);
List.SetImageList(m_pImg, LVSIL_SMALL);

Above you can see how I create ImageList for
C++
CListCtrl
in
C++
OnInitDialog()
, and also set this list to my control.
Here you can see how I add columns:
SQL
List.InsertColumn(0, _T("A"), LVCFMT_LEFT, NUM_COL);
List.InsertColumn(1, _T("B"), LVCFMT_LEFT, NAME_COL);
List.InsertColumn(2, _T("C"), LVCFMT_LEFT, TAG_COL);

I get some image and add it to my list
ASM
HICON icon = some image;
m_pImg->Add(icon);

Under above code following this:
C++
List.InsertItem(i, forNum); // Add some text to A column
List.SetItemText(i, 1, Name); // Add name to B column (I need picture in each row of B column!!!)
//I tried this but it didn't help:
//SetItem(i, 1, LVIF_TEXT|LVIF_IMAGE, Name, 1, NULL, NULL, 0, 0);
List.SetItemText(i, 2, C);// add some text to third columns


I need picture in rows of second column B, but I get picture in rows of first column A. I don't know why
I have a few type of images. How can I add different images to different rows

Thank you!

PS I hope my question will help everybody who is beginner in MFC!
Posted

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