// Example// The pointer to my list view control. extern CListCtrl* pmyListCtrl;CString strText; int nColumnCount = pmyListCtrl->GetHeaderCtrl()->GetItemCount();// Insert 10 items in the list view control. for (int i=0;i < 10;i++) { strText.Format(TEXT("item %d"), i); // Insert the item, select every other item. pmyListCtrl->InsertItem( LVIF_TEXT|LVIF_STATE, i, strText, (i%2)==0 ? LVIS_SELECTED : 0, LVIS_SELECTED, 0, 0); // Initialize the text of the subitems. for (int j=1;j < nColumnCount;j++) { strText.Format(TEXT("sub-item %d %d"), i, j); pmyListCtrl->SetItemText(i, j, strText); } }Example// The pointer to my list view control. extern CListCtrl* pmyListCtrl; // The pointer where the mouse was clicked. extern CPoint myPoint;// Select the item the user clicked on. UINT uFlags; int nItem = pmyListCtrl->HitTest(myPoint, &uFlags);if (uFlags & LVHT_ONITEMLABEL) { pmyListCtrl->SetItem(nItem, 0, LVIF_STATE, NULL, 0, LVIS_SELECTED, LVIS_SELECTED, 0); } 右键CListCtrl控件,可以增加控件消息响应函数 其实去搜索引擎,一搜,肯定很多的例子代码。
// Example// The pointer to my list view control.
extern CListCtrl* pmyListCtrl;CString strText;
int nColumnCount = pmyListCtrl->GetHeaderCtrl()->GetItemCount();// Insert 10 items in the list view control.
for (int i=0;i < 10;i++)
{
strText.Format(TEXT("item %d"), i); // Insert the item, select every other item.
pmyListCtrl->InsertItem(
LVIF_TEXT|LVIF_STATE, i, strText,
(i%2)==0 ? LVIS_SELECTED : 0, LVIS_SELECTED,
0, 0); // Initialize the text of the subitems.
for (int j=1;j < nColumnCount;j++)
{
strText.Format(TEXT("sub-item %d %d"), i, j);
pmyListCtrl->SetItemText(i, j, strText);
}
}Example// The pointer to my list view control.
extern CListCtrl* pmyListCtrl;
// The pointer where the mouse was clicked.
extern CPoint myPoint;// Select the item the user clicked on.
UINT uFlags;
int nItem = pmyListCtrl->HitTest(myPoint, &uFlags);if (uFlags & LVHT_ONITEMLABEL)
{
pmyListCtrl->SetItem(nItem, 0, LVIF_STATE, NULL, 0, LVIS_SELECTED,
LVIS_SELECTED, 0);
}
右键CListCtrl控件,可以增加控件消息响应函数
其实去搜索引擎,一搜,肯定很多的例子代码。