how can i get the current selected item from listcontrol.
-
hi thanx i hav tried like this
Position pos = m_listctrl.GetFirstSelectedItemPosition();
str = m_listctrl.GetItemText(pos,1);then it gives me error
error C2664: 'CString CListCtrl::GetItemText(int,int) const' : cannot convert parameter 1 from 'POSITION' to 'int'
how to get the current index in int format. thanx
You have to use GetNextSelectedItem(Pos)to get the item index, this will return the item index as 'int', use this 'int' value in GetItemText() and assign 0(zero) to subitem if you are not using the ListCtrl in Report View
-
hi thanx i hav tried like this
Position pos = m_listctrl.GetFirstSelectedItemPosition();
str = m_listctrl.GetItemText(pos,1);then it gives me error
error C2664: 'CString CListCtrl::GetItemText(int,int) const' : cannot convert parameter 1 from 'POSITION' to 'int'
how to get the current index in int format. thanx
You have to use GetNextSelectedItem()to get the item index, this will return the item index as 'int', use this 'int' value in GetItemText() and assign 0(zero) to subitem if you are not using the ListCtrl in Report View
-
You have to use GetNextSelectedItem()to get the item index, this will return the item index as 'int', use this 'int' value in GetItemText() and assign 0(zero) to subitem if you are not using the ListCtrl in Report View
hi thanx its working now but there is a problem.. i get the seleted string into the String variable and displaying the it in the MessageBox(). what is happing when i click on any item it shows the text but it shows the messagebox three time. why is this happening.......plz tell me thanx
-
You have to use GetNextSelectedItem()to get the item index, this will return the item index as 'int', use this 'int' value in GetItemText() and assign 0(zero) to subitem if you are not using the ListCtrl in Report View
ok tell me which message i should pass for selecting item in listControl. for a simple list box there is lvnselchange message. but for a ListControl which one should i use. thanx
-
Try this CListCtrl::GetSelectionMark Regards, FarPointer Blog:FARPOINTER
which message i should pass for selecting item in listControl.
-
how can i get the current selected item from listcontrol. thanx
If you are using MFC, use the
CListCtrl::GetNextItem(-1, LVNI_SELECTED)
method.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
-
hi thanx its working now but there is a problem.. i get the seleted string into the String variable and displaying the it in the MessageBox(). what is happing when i click on any item it shows the text but it shows the messagebox three time. why is this happening.......plz tell me thanx
aavesh wrote:
what is happing when i click on any item it shows the text but it shows the messagebox three time.
It sounds as though you are responding to the
LVN_ITEMCHANGED
message. When you select an item, more than one item has changed at that point. Study theNMLISTVIEW
structure for details.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
-
which message i should pass for selecting item in listControl.
-
If you are using MFC, use the
CListCtrl::GetNextItem(-1, LVNI_SELECTED)
method.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
will this function return me the current item ..when i tried this function it give me error "LVS_SELECTED is uncdeclare identifier" thanx
-
will this function return me the current item ..when i tried this function it give me error "LVS_SELECTED is uncdeclare identifier" thanx
It's considered good practice to read the documentation to confirm/verify what you read here. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/listview/messages/lvm_getnextitem.asp[^]
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
-
will this function return me the current item ..when i tried this function it give me error "LVS_SELECTED is uncdeclare identifier" thanx
This is not implemented :-
LVS_SELECTED
Regards, FarPointer Blog:FARPOINTER