Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listview problem

Status
Not open for further replies.

bernardsylunar

Programmer
Feb 9, 2005
25
PH
hi everyone...

i'll go straight to the problem. i create a simple intranet e-mail program which we will be using within our company. i am using a listview control to display the message. previously, i used ItemClick procedure to open a certain message. then i added a popup menu so the user would have more options when he/she right-click on the listview control.

-------
here's my code on ItemClick Procedure


Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
'function to open the item clicked by the user
If ListView1.ListItems.Count = 0 Then Exit Sub
'function to open a message
OpenMessage
End Sub

Private Sub ListView1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 2 Then
popupMenu Menu
End If
End Sub

-------------------------

the problem is when the user right-click on the listview control, the ItemClick procedure is triggered. so, instead of using ItemClick procedure, i shifted to DblClick Procedure to open a certain message. but everytime i double click on the listview control even without pointing at the message listed on it, the DblClick procedure is triggered and the selected message will be opened.

what i want to do is for the DblClick procedure to be triggered only when i double click on the item(s) listed and not when i double click anywhere on the listview control. how can i do that? do i missed some listview procedure or do i have to use any API? pls help..

i hope my explanation is clear.

any help will be greatly appreciated...

thanks in advance.

ynad
----
It is foolish to listen to someone who will not listen to you.
 
You can check the Selected propertry of the selected listitem. If you double-click on an item, it is selected and highlighted. If you double-click elsewhere, the selected item is selected but not highlighted.
___
[tt]
Private Sub ListView1_DblClick()
'if there is no selected item, then exit
If ListView1.SelectedItem Is Nothing Then Exit Sub
'if selected item is selected, then open message
If ListView1.SelectedItem.Selected Then OpenMessage
End Sub[/tt]
 
Hypetia, thanks for your reply.

i've done what you said but the focus is always on my listview control and there's always a highlighted item. and everytime i double click anywhere on the listview control (not on the selected item), the selected item still opens.

thanks again


ynad
----
It is foolish to listen to someone who will not listen to you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top