Udostępnij za pośrednictwem


CHeaderCtrl::InsertItem

Wstawia nowy element do nagłówka formantu pod określonym indeksem.

int InsertItem(
   int nPos,
   HDITEM* phdi 
);

Parametry

  • nPos
    Indeks elementu dodaje się od zera.Jeśli wartość wynosi zero, element jest wstawiany na początku nagłówka formantu.Jeśli wartość jest większa niż maksymalna wartość, element jest wstawiany na końcu nagłówka formantu.

  • phdi
    Wskaźnik do HDITEM strukturę, która zawiera informacje o elemencie dodaje się.

Wartość zwracana

Indeks nowego elementu w przypadku powodzenia; w przeciwnym razie – 1.

Przykład

CString str;
HDITEM  hdi;

hdi.mask = HDI_TEXT | HDI_WIDTH | HDI_FORMAT | HDI_IMAGE;
hdi.cxy = 100; // Make all columns 100 pixels wide.
hdi.fmt = HDF_STRING | HDF_CENTER;

// Insert 6 columns in the header control.
for (int i=0; i < 6; i++)
{
   str.Format(TEXT("column %d"), i);
   hdi.pszText = str.GetBuffer(0);
   hdi.iImage = i % 3;

   m_myHeaderCtrl.InsertItem(i, &hdi);
}

Wymagania

Nagłówek: afxcmn.h

Zobacz też

Informacje

Klasa CHeaderCtrl

Wykres hierarchii

CHeaderCtrl::DeleteItem

CHeaderCtrl::GetItem