Re: vb-listview-plz help me out



deepa.kr@xxxxxxxxxxxxxxx wrote:
> hi all.i have two listview's and i add items from one listview to
> another.i have the code below:
> Private Sub Command3_Click()
> Dim i As Integer
> For i = 1 To ListView1.ListItems.Count
> If ListView1.ListItems(i).Selected Then
> ListView2.ListItems.Add , , ListView1.ListItems(i).Text,
> ListView1.ListItems(i).Icon
> End If
> Next i
> For i = ListView1.ListItems.Count To 1 Step -1
> If ListView1.ListItems(i).Selected Then
> ListView1.ListItems.Remove (i)
> End If
> Next i
> End Sub
>
> The problem with the above is when the form gets loaded for the first
> time,the first item in the listview is moved to the second
> listview,without selecting the item, when i click the command button.
> if i place a breakpoint on "If ListView1.ListItems(i).Selected Then "
> the value shown is TRUE....but i have not at all selected the
> listviewitem....

Obviously, if the Selected property is true, then the item is selected.
Basically, the first item is selected by default. To deselect after load,
use this: -

If Not ListView1.SelectedItem Is Nothing Then
ListView1.SelectedItem.Selected = False
Set ListView1.SelectedItem = Nothing
End If



--
Regards,

Michael Cole


.