Partager via


CListBox::SetAnchorIndex

Sets the anchor in a multiple-selection list box to begin an extended selection.

void SetAnchorIndex(
   int nIndex 
);

Parameters

  • nIndex
    Specifies the zero-based index of the list-box item that will be the anchor.

Remarks

In a multiple-selection list box, the anchor item is the first or last item in a block of contiguous selected items.

Example

void CMyODListBox::OnLButtonDown(UINT nFlags, CPoint point)
{
   BOOL bOutside = TRUE;
   UINT uItem = ItemFromPoint(point, bOutside);

   if (!bOutside)
   {
      // Set the anchor to be the middle item.
      SetAnchorIndex(uItem);
      ASSERT((UINT)GetAnchorIndex() == uItem);
   }

   CListBox::OnLButtonDown(nFlags, point);
}

Requirements

Header: afxwin.h

See Also

Reference

CListBox Class

Hierarchy Chart

CListBox::GetAnchorIndex

Other Resources

CListBox Members