Help and Support

Article ID: 262417 - Last Review: October 15, 2002 - Revision: 1.0

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

This article was previously published under Q262417

On This Page

Expand all | Collapse all

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.

APPLIES TO
  • Microsoft eMbedded Visual Basic 3.0
Keywords: 
kbbug kbpending kbprb KB262417
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.

Article Translations