本文介绍了列表控件子项消失了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是将项目插入listcontrl的代码.
当我将LVIF_PARAM
添加到lvi.mask
时,仅显示第一个子项. (列表控件设置为报告查看模式).这是什么问题?
Hi,
The following is code to insert an item to listcontrl.
When i add LVIF_PARAM
to lvi.mask
, only first subitem is shown. (list control is set as report view mode). What is problem here??
m_lstCtrl.InsertColumn(0, L"First name" , LVCFMT_LEFT, onePercent * 35);
m_lstCtrl.InsertColumn(1, L"Middle name", LVCFMT_CENTER, onePercent * 35);
m_lstCtrl.InsertColumn(2, L"Last name", LVCFMT_LEFT, onePercent * 30);
LVITEM lvi;
// Insert #0
// Check if image available
lvi.mask = LVIF_TEXT | LVIF_PARAM ;
lvi.iItem = 0;
lvi.iSubItem = 0;
lvi.lParam = 100;
lvi.pszText =L"First";
m_lstCtrl.InsertItem(&lvi);
// Insert #1
lvi.iSubItem = 1;
lvi.pszText = L"Middle";
m_lstCtrl.SetItem(&lvi);
// Insert #2
lvi.iSubItem = 2;
lvi.pszText = L"Last";
m_lstCtrl.SetItem(&lvi);
谢谢.
Quy
Thank.
Quy
推荐答案
m_lstCtrl.InsertColumn(0, L"First name" , LVCFMT_LEFT, onePercent * 35);
m_lstCtrl.InsertColumn(1, L"Middle name", LVCFMT_CENTER, onePercent * 35);
m_lstCtrl.InsertColumn(2, L"Last name", LVCFMT_LEFT, onePercent * 30);
LVITEM lvi;
// Insert First#0
// Check if image available
lvi.mask = LVIF_TEXT | LVIF_PARAM ;
lvi.iItem = 0;
lvi.iSubItem = 0;
lvi.lParam = 100;
lvi.pszText =L"First";
m_lstCtrl.InsertItem(&lvi);
// Insert Middle#1
lvi.mask = LVIF_TEXT;
lvi.iSubItem = 1;
lvi.pszText = L"Middle";
m_lstCtrl.SetItem(&lvi);
// Insert Last#2
lvi.mask = LVIF_TEXT;
lvi.iSubItem = 2;
lvi.pszText = L"Last";
m_lstCtrl.SetItem(&lvi);
Quy
Quy
这篇关于列表控件子项消失了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!