插入新项添加到指定的索引的一个标头控件。
int InsertItem(
int nPos,
HDITEM* phdi
);
参数
nPos
要插入的项的索引(索引从零开始)。如果该值为零,该项目在标头控件的开头插入。如果该值大于最大值,该项目会插入到标头控件的末尾。phdi
对包含有关要插入的项的信息的 HDITEM 结构的指针。
返回值
新的项的索引,如果成功;否则– 1。
示例
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);
}
要求
Header: afxcmn.h