Microsoft KB Archive/262417

= BUG: eVB: ListView: Comparison Statement with Selected Property Fails =

Article ID: 262417

Article Last Modified on 10/15/2002

-

APPLIES TO


 * Microsoft eMbedded Visual Basic 3.0

-



This article was previously published under Q262417



SYMPTOMS
If you compare the Selected property of the ListView control with True, the comparison fails.



RESOLUTION
To work around this problem, do not compare the Selected property with True. Replace the Command1_Click event code in the sample under &quot;Steps to Reproduce Behavior&quot; with the following: Private Sub Command1_Click If ListViewCtrl1.ListItems.Item(1).Selected Then MsgBox &quot;Item1 selected&quot; Else MsgBox &quot;Item1 not selected&quot; End If End Sub



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



Steps to Reproduce Behavior
 Open Microsoft eMbedded Visual Basic 3.0. Create a new Windows CE project for the Pocket PC. Form1 is created by default. On the Project menu, click to select Components, and then add the Microsoft CE ListView Control 3.0. Add one ListView control and two CommandButton controls to Form1.  Paste the following code into Form1: Option Explicit

Private Sub Command1_Click If ListViewCtrl1.ListItems.Item(1).Selected = True Then MsgBox &quot;Item1 selected&quot; Else MsgBox &quot;Item1 not selected&quot; End If End Sub

Private Sub Command2_Click App.End End Sub

Private Sub Form_Activate ListViewCtrl1.ListItems.Add, , &quot;One&quot; ListViewCtrl1.ListItems.Add, , &quot;Two&quot; End Sub  Run the project, select item One in the ListView control, and then click on Command1. The expected behavior is that a message box with Item1 selected appears. Instead, the message box displays Item1 not Selected.</li></ol>

Additional query words: wce evb

Keywords: kbbug kbprb kbpending KB262417

-

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

© Microsoft Corporation. All rights reserved.