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
| BOOL CFenetreDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
Liste.InsertColumn(1,L"",LVCFMT_LEFT,23);
Liste.InsertColumn(2,L"Date",LVCFMT_LEFT,45);
Liste.InsertColumn(3,L"Name",LVCFMT_LEFT,80);
Liste.InsertColumn(4,L"Number",LVCFMT_LEFT,110);
Liste.InsertColumn(5,L"Test?",LVCFMT_LEFT,55);
CString strText;
Liste.SetExtendedStyle(Liste.GetExtendedStyle() | LVS_EX_GRIDLINES | LVS_EX_CHECKBOXES);
// 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.
Liste.InsertItem(LVIF_TEXT | LVIF_STATE, i, 0, 0, LVIS_SELECTED, 0, 0);
ListView_SetCheckState(Liste. GetSafeHwnd( ), i, TRUE);
// Initialize the text of the subitems.
for (int j = 1; j < 5; j++)
{
if (j == 4)
{
Liste.SetItem(i, j, LVIF_STATE, 0, 0, LVIS_SELECTED, 0, 0);
}
else
{
strText.Format(TEXT("sub-item %d %d"), i, j);
Liste.SetItemText(i, j, strText);
}
}
}
return TRUE;
} |
Partager