Guest Jack Posted July 20, 2008 Posted July 20, 2008 Hello, When the item is selected I need to enable cmdDelete btn. and if there is not item selected cmdDelete btn must be disabled. The problem with the code I use (see below) is that when user change the selected item (or when user select item for the first time) the code below does not "see" selected item with the first mouse click. Private Sub lvSelLines_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) For i = lvSelLines.ListItems.Count To 1 Step -1 If lvSelLines.ListItems(i).Selected = True Then cmdDelete.Enabled = True Exit Sub End If Next cmdDelete.Enabled = False End Sub How to correct that? Jack
Guest Jack Posted July 20, 2008 Posted July 20, 2008 Re: ListView: how to detect if the item is selected with the first mouse click? Sorry, wrong forum. Jack "Jack" <replyto@it> wrote in message news:%23vl%234oo6IHA.3480@TK2MSFTNGP03.phx.gbl... > Hello, > When the item is selected I need to enable cmdDelete btn. > and if there is not item selected cmdDelete btn must be disabled. > The problem with the code I use (see below) is that when user change the > selected item (or when user select item for the first time) the code below > does not "see" selected item with the first mouse click. > > Private Sub lvSelLines_MouseDown(Button As Integer, Shift As Integer, x As > Single, y As Single) > For i = lvSelLines.ListItems.Count To 1 Step -1 > If lvSelLines.ListItems(i).Selected = True Then > cmdDelete.Enabled = True > Exit Sub > End If > Next > cmdDelete.Enabled = False > End Sub > > How to correct that? > Jack > >
Recommended Posts