1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| void MaListe::OnInitialUpdate()
{
CListView::OnInitialUpdate();
CListCtrl& theCtrl = GetListCtrl();
// TODO: You may populate your ListView with items by directly accessing
CString strText;
for(int nc=0;nc<5;nc++)
{
strText.Format(TEXT("ColHeader%d"),nc);
theCtrl.InsertColumn(nc,strText,LVCFMT_LEFT,70);
}
theCtrl.ModifyStyle(0,LVS_REPORT);
theCtrl.SetExtendedStyle(theCtrl.GetExtendedStyle() | LVS_EX_FULLROWSELECT );
for (int i=0;i < 10;i++)
{
strText.Format(TEXT("item %d"), i);
// Insert the item, select every other item.
theCtrl.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<theCtrl.GetHeaderCtrl()->GetItemCount();j++)
{
strText.Format(TEXT("Sub-Item %d %d"), i, j);
theCtrl.SetItemText(i, j, strText);
}
}
} |
Partager