我的clistctrl中有很多行,当我用鼠标点击其中一行的时候,我怎样获得当前的行数??

解决方案 »

  1.   

    GetFirstSelectedItem
    GetNextSelectedItem int GetNextSelectedItem( POSITION& pos ) const;Return ValueThe index of the next selected item in the list view control.
      

  2.   

    GetFirstSelectedItemPosition
    GetNextSelectedItem int GetNextSelectedItem( POSITION& pos ) const;Return ValueThe index of the next selected item in the list view control.
      

  3.   

    添加类向导使控件处理鼠标消息响应
    例如:
    void OnRclickList2(NMHDR* pNMHDR, LRESULT* pResult) 
    {
    NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
    // TODO: Add your control notification handler code here
    //pNMListView->iItem行数
             //pNMListView->iSubItem列数

    *pResult = 0;
    }
      

  4.   

    Use CListCtrl::GetFirstSelectedItemPosition() to get the first selected item - if any. With CListCtrl::GetNextSelectedItem() you may iterate thru all selected items or refuese deletion if more than one is selected.
      

  5.   

    int row = m_MainList.GetNextItem(-1,LVNI_SELECTED);