Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Visual C++/MFC/WTL > Visual C++ 6.0 — List Control


Автор: Gryphon 20.3.2006, 16:46
Помогите, пожалуйста! Как с этой гадостью работать?
Диалог. Надо в этот самый List Ctrl вывести массив целых чисел. Как???

Автор: Earnest 20.3.2006, 17:49
У ListCtrl есть функция - InsertItem.

Автор: Gryphon 20.3.2006, 18:02
Earnest
Опишите её, пожалуйста
А то приличной книги под рукой нет

Автор: Earnest 20.3.2006, 18:49
Цитата(MSDN)

int InsertItem (const LVITEM* pItem);
int InsertItem (int nItem,LPCTSTR lpszItem);
int InsertItem (int nItem,LPCTSTR lpszItem,int nImage);

Parameters

pItem
Pointer to an LVITEM structure that specifies the item's attributes, as described in the Platform SDK.

nItem
Index of the item to be inserted.

lpszItem
Address of a string containing the item's label, or LPSTR_TEXTCALLBACK if the item is a callback item. For information
on callback items, see CListCtrl::GetCallbackMask.

nImage
Index of the item's image, or I_IMAGECALLBACK if the item is a callback item. For information on callback items, see CListCtrl::GetCallbackMask.

Return Value
The index of the new item if successful or -1 otherwise.

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);
  }
}

Автор: Gryphon 24.3.2006, 18:32
Пасиб)

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)