Why does the previous selected item in a ListView get selected for a short moment 
Author Message
 Why does the previous selected item in a ListView get selected for a short moment

I've a Form with 2 ListViews.
I click on an item of ListView1 and then on an item of ListView2.
If you click now on another item of ListView1 you will see that the item
which was selected
before will be highlighted for a short moment before the item you've
just selected gets highlighted.
If the ListViews are quite long and you have icons in the ListView this
effect is more significant.

Does anyone have any idea how to prevent the flickering of the previous
selected item?
Stefan

***** SAMPLE CODE *****

Option Explicit

Private Sub Form_Load()
  Dim i As Integer

  Form1.Height = 10000
  Form1.Width = 10000

  With ListView1
      .Left = 500
      .Top = 500
      .Width = 4000
      .Height = 9000
      .View = lvwReport
      .GridLines = True
      .HideColumnHeaders = True
      .ColumnHeaders.Add
      .ColumnHeaders.Add
      .ColumnHeaders.Add
      .ColumnHeaders.Add
      .ColumnHeaders.Add
      .ColumnHeaders.Add
      For i = 1 To 1000
        .ListItems.Add = "Test Item " & i
        .ListItems(i).SubItems(1) = "Test Item " & i
        .ListItems(i).SubItems(2) = "Test Item " & i
        .ListItems(i).SubItems(3) = "Test Item " & i
        .ListItems(i).SubItems(4) = "Test Item " & i
        .ListItems(i).SubItems(5) = "Test Item " & i
      Next
  End With

  With ListView2
      .Left = 5500
      .Top = 500
      .Width = 4000
      .Height = 9000
      .View = lvwReport
      .GridLines = True
      .HideColumnHeaders = True
      .ColumnHeaders.Add
      .ColumnHeaders.Add
      .ColumnHeaders.Add
      .ColumnHeaders.Add
      .ColumnHeaders.Add
      .ColumnHeaders.Add
      For i = 1 To 1000
        .ListItems.Add = "Test Item " & i
        .ListItems(i).SubItems(1) = "Test Item " & i
        .ListItems(i).SubItems(2) = "Test Item " & i
        .ListItems(i).SubItems(3) = "Test Item " & i
        .ListItems(i).SubItems(4) = "Test Item " & i
        .ListItems(i).SubItems(5) = "Test Item " & i
      Next
  End With
End Sub



Sat, 21 May 2005 02:36:53 GMT  
 Why does the previous selected item in a ListView get selected for a short moment
Try to in ListView1_LostFocus() set focus to some control outside ListView1.
/Henning



Quote:
> I've a Form with 2 ListViews.
> I click on an item of ListView1 and then on an item of ListView2.
> If you click now on another item of ListView1 you will see that the item
> which was selected
> before will be highlighted for a short moment before the item you've
> just selected gets highlighted.
> If the ListViews are quite long and you have icons in the ListView this
> effect is more significant.

> Does anyone have any idea how to prevent the flickering of the previous
> selected item?
> Stefan

> ***** SAMPLE CODE *****

> Option Explicit

> Private Sub Form_Load()
>   Dim i As Integer

>   Form1.Height = 10000
>   Form1.Width = 10000

>   With ListView1
>       .Left = 500
>       .Top = 500
>       .Width = 4000
>       .Height = 9000
>       .View = lvwReport
>       .GridLines = True
>       .HideColumnHeaders = True
>       .ColumnHeaders.Add
>       .ColumnHeaders.Add
>       .ColumnHeaders.Add
>       .ColumnHeaders.Add
>       .ColumnHeaders.Add
>       .ColumnHeaders.Add
>       For i = 1 To 1000
>         .ListItems.Add = "Test Item " & i
>         .ListItems(i).SubItems(1) = "Test Item " & i
>         .ListItems(i).SubItems(2) = "Test Item " & i
>         .ListItems(i).SubItems(3) = "Test Item " & i
>         .ListItems(i).SubItems(4) = "Test Item " & i
>         .ListItems(i).SubItems(5) = "Test Item " & i
>       Next
>   End With

>   With ListView2
>       .Left = 5500
>       .Top = 500
>       .Width = 4000
>       .Height = 9000
>       .View = lvwReport
>       .GridLines = True
>       .HideColumnHeaders = True
>       .ColumnHeaders.Add
>       .ColumnHeaders.Add
>       .ColumnHeaders.Add
>       .ColumnHeaders.Add
>       .ColumnHeaders.Add
>       .ColumnHeaders.Add
>       For i = 1 To 1000
>         .ListItems.Add = "Test Item " & i
>         .ListItems(i).SubItems(1) = "Test Item " & i
>         .ListItems(i).SubItems(2) = "Test Item " & i
>         .ListItems(i).SubItems(3) = "Test Item " & i
>         .ListItems(i).SubItems(4) = "Test Item " & i
>         .ListItems(i).SubItems(5) = "Test Item " & i
>       Next
>   End With
> End Sub



Sat, 21 May 2005 04:01:36 GMT  
 Why does the previous selected item in a ListView get selected for a short moment
Hi Henning

I added

  Private Sub ListView1_LostFocus()
    Text1.SetFocus
  End Sub

  Private Sub ListView2_LostFocus()
    Text1.SetFocus
  End Sub

but unfortunately it doesn't solve the problem.
Stefan

Quote:

> Try to in ListView1_LostFocus() set focus to some control outside ListView1.
> /Henning



> > I've a Form with 2 ListViews.
> > I click on an item of ListView1 and then on an item of ListView2.
> > If you click now on another item of ListView1 you will see that the item
> > which was selected
> > before will be highlighted for a short moment before the item you've
> > just selected gets highlighted.
> > If the ListViews are quite long and you have icons in the ListView this
> > effect is more significant.

> > Does anyone have any idea how to prevent the flickering of the previous
> > selected item?
> > Stefan

> > ***** SAMPLE CODE *****

> > Option Explicit

> > Private Sub Form_Load()
> >   Dim i As Integer

> >   Form1.Height = 10000
> >   Form1.Width = 10000

> >   With ListView1
> >       .Left = 500
> >       .Top = 500
> >       .Width = 4000
> >       .Height = 9000
> >       .View = lvwReport
> >       .GridLines = True
> >       .HideColumnHeaders = True
> >       .ColumnHeaders.Add
> >       .ColumnHeaders.Add
> >       .ColumnHeaders.Add
> >       .ColumnHeaders.Add
> >       .ColumnHeaders.Add
> >       .ColumnHeaders.Add
> >       For i = 1 To 1000
> >         .ListItems.Add = "Test Item " & i
> >         .ListItems(i).SubItems(1) = "Test Item " & i
> >         .ListItems(i).SubItems(2) = "Test Item " & i
> >         .ListItems(i).SubItems(3) = "Test Item " & i
> >         .ListItems(i).SubItems(4) = "Test Item " & i
> >         .ListItems(i).SubItems(5) = "Test Item " & i
> >       Next
> >   End With

> >   With ListView2
> >       .Left = 5500
> >       .Top = 500
> >       .Width = 4000
> >       .Height = 9000
> >       .View = lvwReport
> >       .GridLines = True
> >       .HideColumnHeaders = True
> >       .ColumnHeaders.Add
> >       .ColumnHeaders.Add
> >       .ColumnHeaders.Add
> >       .ColumnHeaders.Add
> >       .ColumnHeaders.Add
> >       .ColumnHeaders.Add
> >       For i = 1 To 1000
> >         .ListItems.Add = "Test Item " & i
> >         .ListItems(i).SubItems(1) = "Test Item " & i
> >         .ListItems(i).SubItems(2) = "Test Item " & i
> >         .ListItems(i).SubItems(3) = "Test Item " & i
> >         .ListItems(i).SubItems(4) = "Test Item " & i
> >         .ListItems(i).SubItems(5) = "Test Item " & i
> >       Next
> >   End With
> > End Sub



Tue, 24 May 2005 15:29:33 GMT  
 Why does the previous selected item in a ListView get selected for a short moment
On Fri, 06 Dec 2002 08:29:33 +0100, Stefan Mueller

Quote:

>Hi Henning

>I added

>  Private Sub ListView1_LostFocus()
>    Text1.SetFocus
>  End Sub

>  Private Sub ListView2_LostFocus()
>    Text1.SetFocus
>  End Sub

>but unfortunately it doesn't solve the problem.
>Stefan

I think we (this group) may have got around that here once by
deselecting on mousedown, when hittest didn't equal the current
selection.  Not sure about it though, so i may be totally off track..

Try it and see.. off the top of my head it would have looked like this

Listview_MouseDown(bla, x, y)
        dim aNode as Listitem
        set Anode = listview.Hittest(x,y)
        if not anode is Nothing then
                if anode = ListView.SelectedItem Then
                        aNode.Selected = False
                endif
                set Anode = Nothing
        endif
End Sub                                

--
Regards, Frank



Tue, 24 May 2005 16:57:11 GMT  
 Why does the previous selected item in a ListView get selected for a short moment
Hi Frank

I'm not sure if we are talking about the same problem, because if you
get control in the MouseDown event it's already to later, because at
that moment the previous selected row got already highlighted.
What I'd like is to prevent that the previous selected row gets
highlighted for a short time before the actual clicked row gets
highlighted.

Stefan

Quote:

> On Fri, 06 Dec 2002 08:29:33 +0100, Stefan Mueller

> >Hi Henning

> >I added

> >  Private Sub ListView1_LostFocus()
> >    Text1.SetFocus
> >  End Sub

> >  Private Sub ListView2_LostFocus()
> >    Text1.SetFocus
> >  End Sub

> >but unfortunately it doesn't solve the problem.
> >Stefan

> I think we (this group) may have got around that here once by
> deselecting on mousedown, when hittest didn't equal the current
> selection.  Not sure about it though, so i may be totally off track..

> Try it and see.. off the top of my head it would have looked like this

> Listview_MouseDown(bla, x, y)
>         dim aNode as Listitem
>         set Anode = listview.Hittest(x,y)
>         if not anode is Nothing then
>                 if anode = ListView.SelectedItem Then
>                         aNode.Selected = False
>                 endif
>                 set Anode = Nothing
>         endif
> End Sub

> --
> Regards, Frank

I've a Form with 2 ListViews.
I click on an item of ListView1 and then on an item of ListView2.
If you click now on another item of ListView1 you will see that the item
which was selected
before will be highlighted for a short moment before the item you've
just selected gets highlighted.
If the ListViews are quite long and you have icons in the ListView this
effect is more significant.

Does anyone have any idea how to prevent the flickering of the previous
selected item?
Stefan

***** SAMPLE CODE *****

Option Explicit

Private Sub Form_Load()
  Dim i As Integer

  Form1.Height = 10000
  Form1.Width = 10000

  With ListView1
      .Left = 500
      .Top = 500
      .Width = 4000
      .Height = 9000
      .View = lvwReport
      .GridLines = True
      .HideColumnHeaders = True
      .ColumnHeaders.Add
      .ColumnHeaders.Add
      .ColumnHeaders.Add
      .ColumnHeaders.Add
      .ColumnHeaders.Add
      .ColumnHeaders.Add
      For i = 1 To 1000
        .ListItems.Add = "Test Item " & i
        .ListItems(i).SubItems(1) = "Test Item " & i
        .ListItems(i).SubItems(2) = "Test Item " & i
        .ListItems(i).SubItems(3) = "Test Item " & i
        .ListItems(i).SubItems(4) = "Test Item " & i
        .ListItems(i).SubItems(5) = "Test Item " & i
      Next
  End With

  With ListView2
      .Left = 5500
      .Top = 500
      .Width = 4000
      .Height = 9000
      .View = lvwReport
      .GridLines = True
      .HideColumnHeaders = True
      .ColumnHeaders.Add
      .ColumnHeaders.Add
      .ColumnHeaders.Add
      .ColumnHeaders.Add
      .ColumnHeaders.Add
      .ColumnHeaders.Add
      For i = 1 To 1000
        .ListItems.Add = "Test Item " & i
        .ListItems(i).SubItems(1) = "Test Item " & i
        .ListItems(i).SubItems(2) = "Test Item " & i
        .ListItems(i).SubItems(3) = "Test Item " & i
        .ListItems(i).SubItems(4) = "Test Item " & i
        .ListItems(i).SubItems(5) = "Test Item " & i
      Next
  End With
End Sub



Thu, 26 May 2005 22:46:56 GMT  
 Why does the previous selected item in a ListView get selected for a short moment
On Sun, 08 Dec 2002 15:46:56 +0100, Stefan Mueller

Quote:

>Hi Frank

>I'm not sure if we are talking about the same problem, because if you
>get control in the MouseDown event it's already to later, because at
>that moment the previous selected row got already highlighted.
>What I'd like is to prevent that the previous selected row gets
>highlighted for a short time before the actual clicked row gets
>highlighted.

How about setting HideSelection to False ? It probably still does it,
but it is not (or not as) noticable as the item stays highlighted.
More like an optical illusion, but see if it does the trick.  

--
Regards, Frank



Sat, 28 May 2005 16:21:34 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. How to prevent flickering of the previous selected item in a ListView

2. ListView control - Keeping selected items looking selected

3. jump listview to the hilight item (selected item)...

4. Determine Selected Folder and Selected Item in Folder

5. Selecting items in a DB-list and passing fields from selected rec to a control

6. selecting items in a Data bound list and passing a field content for the selected record

7. How to simulate selecting an item in a select element

8. Selecting Items in a SELECT List

9. Selecting the Selected Item

10. ListView Control - Removing selected items from the list

11. List of selected items in a listview

12. ListView - How to programatically select an item

 

 
Powered by phpBB® Forum Software