即,我想設定ListCtrl中的某一項處於可視區的最上方,在ListBox中有SetTopIndex()函數,但在ListCtrl中找不到相類似的函數啊?

解决方案 »

  1.   

    CComboBox::SetTopIndex
    int SetTopIndex( int nIndex );Return ValueZero if successful, or LB_ERR if an error occurs.ParametersnIndexSpecifies the zero-based index of the list-box item.ResEnsures that a particular item is visible in the list-box portion of the combo box.The system scrolls the list box until either the item specified by nIndex appears at the top of the list box or the maximum scroll range has been reached.將要放到最上方的index傳給該函數即可
      

  2.   

    SetTopIndex()不是ListCtrl的成員函數啊,ListBox用這個函數可以。
      

  3.   

    CListCtrl::EnsureVisible配合CListCtrl::Scroll使用下面的例子是确保最后一个item可见:
    int nCount = pmyListCtrl->GetItemCount();
    if (nCount > 0)
       pmyListCtrl->EnsureVisible(nCount-1, FALSE);