BUG: eVB: ListView: Comparison Statement with Selected Property Fails (262417)



The information in this article 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 "Steps to Reproduce Behavior" with the following:
Private Sub Command1_Click()
    If ListViewCtrl1.ListItems.Item(1).Selected Then
        MsgBox "Item1 selected"
    Else
        MsgBox "Item1 not selected"
    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.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Open Microsoft eMbedded Visual Basic 3.0.
  2. Create a new Windows CE project for the Pocket PC. Form1 is created by default.
  3. On the Project menu, click to select Components, and then add the Microsoft CE ListView Control 3.0.
  4. Add one ListView control and two CommandButton controls to Form1.
  5. Paste the following code into Form1:
    Option Explicit
    
    Private Sub Command1_Click()
        If ListViewCtrl1.ListItems.Item(1).Selected = True Then
            MsgBox "Item1 selected"
        Else
            MsgBox "Item1 not selected"
        End If
    End Sub
    
    Private Sub Command2_Click()
        App.End
    End Sub
    
    Private Sub Form_Activate()
        ListViewCtrl1.ListItems.Add , , "One"
        ListViewCtrl1.ListItems.Add , , "Two"
    End Sub
    					
  6. 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.

Modification Type:MajorLast Reviewed:10/15/2002
Keywords:kbBug kbDSupport kbprb KB262417