Microsoft KB Archive/215385

= BUG: ItemClick Event Fires After First ListItem Added to ListView =

Article ID: 215385

Article Last Modified on 8/19/2005

-

APPLIES TO


 * Microsoft Windows CE Toolkit for Visual Basic 6.0

-



This article was previously published under Q215385



SYMPTOMS
The ItemClick event fires after the first ListItem is added to a ListView, even though the item was not clicked.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
The ItemClick event fires only after adding the first item. Adding more items does not fire the ItemClick event.

Steps to Reproduce Behavior
 Start a new Windows CE HPC Project or Windows CE HPC Pro Project in Visual Basic. Form1 is created by default. Select Components from the Project menu and select the Microsoft CE ListView Control 6.0. Add a ListBox, CommandButton, and ListView control to Form1.  Paste the following code into Form1: Private Sub Command1_Click ListViewCtrl1.ListItems.Add, , "Item One" End Sub

Private Sub ListViewCtrl1_ItemClick(ByVal Index As Long) List1.AddItem "ItemClick fired." End Sub  Run the project on the target platform. Click the CommandButton, and note that the first ListItem is added to the ListView and the ItemClick event fires.</li></ol>

WorkAround
You can use the following code as a work around for this behavior: Option Explicit Dim first_time As Boolean Private Sub Command1_Click If first_time Then ListViewCtrl1.ListItems.Add, , "" ListViewCtrl1.ListItems.Add, , "Item One" ListViewCtrl1.ListItems.Remove (1)

first_time = False Else ListViewCtrl1.ListItems.Add, , "Item One" End If  End Sub Private Sub Form_Load first_time = True End Sub Private Sub ListViewCtrl1_ItemClick(ByVal Index As Long) If Not first_time Then List1.AddItem "ItemClick fired." End If  End Sub

Additional query words: vbce vbce6 wince wce

Keywords: kbbug kbtoolkit kbpending KB215385

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.