CListCtrl::GetFirstSelectedItemPosition
POSITION GetFirstSelectedItemPosition( ) const;Return ValueA POSITION value that can be used for iteration or object pointer retrieval; NULL if no items are selected.ResGets the position of the first selected item in the list view control.ExampleThe following code sample demonstrates the usage of this function.CListCtrl* pListCtrl = (CListCtrl*) GetDlgItem(IDC_YOURLISTCONTROL);
ASSERT(pListCtrl != NULL);POSITION pos = pList->GetFirstSelectedItemPosition();
if (pos == NULL)
TRACE0("No items were selected!\n");
else
{
while (pos)
{
int nItem = pList->GetNextSelectedItem(pos);
TRACE1("Item %d was selected!\n", nItem);
// you could do your own processing on nItem here
}
}
POSITION GetFirstSelectedItemPosition( ) const;Return ValueA POSITION value that can be used for iteration or object pointer retrieval; NULL if no items are selected.ResGets the position of the first selected item in the list view control.ExampleThe following code sample demonstrates the usage of this function.CListCtrl* pListCtrl = (CListCtrl*) GetDlgItem(IDC_YOURLISTCONTROL);
ASSERT(pListCtrl != NULL);POSITION pos = pList->GetFirstSelectedItemPosition();
if (pos == NULL)
TRACE0("No items were selected!\n");
else
{
while (pos)
{
int nItem = pList->GetNextSelectedItem(pos);
TRACE1("Item %d was selected!\n", nItem);
// you could do your own processing on nItem here
}
}
解决方案 »
- 为什么我这个串口通信有问题啊
- VC 我在一个对话框怎么获取别一个对话框句柄
- 求翻译
- 关于模态对话框的焦点问题
- CommDlgExtendedError的返回错误FNERR_BUFFERTOOSMALL,如何计算buf长度?
- combox的问题
- 关于GetPixel的问题
- 求助:Debug Assertion Failed!
- sos!各位高手,谁能帮我编个通讯程序???十万火急!
- 大侠帮忙!在classview中doc或view类总会神秘消失,但doc或view的文件还在
- 如何能自由的控制光标
- 我在DLL中输出了一个链表_declspec(dllexport) CList g_list 然后在exe用它,却不对,如何解决这个问题呢?
{
// TODO: Add your control notification handler code here
//OnDblclkListview(NMHDR* pNMHDR, LRESULT* pResult) ;
int i,iState;
int nItemSelected=m_listview.GetSelectedCount();//所选表项数 int nItemCount=m_listview.GetItemCount();//表项总数 if(nItemSelected<1) return; for(i=nItemCount-1;i>=0;i--){
iState=m_listview.GetItemState(i,LVIS_SELECTED);//看是否选中
CString d;
if(!iState==0)
{
d=m_listview.GetItemText(i,0);//这是取得第一列的值,如果去第二列,把0改称1就行了
d.TrimLeft();
d.TrimRight();
m_edit.SetWindowText(d);//改变文本的值
}
}
UpdateData(FALSE);
*pResult = 0;
}