Solved

ListView Clearing and Non-Mouse Click Highlighting

Posted on 1998-02-27
3
268 Views
Last Modified: 2012-05-04
Working with the ListView control i have found that if you were to say highlight a selection in a listview control with your mouse, store this index value, clear the listview completely, then put back the information taht was cleared and manually highlight the previously highlighted selection it wont highlight.  
By going through debug i find that it does highlight just after the line that tells it to rehighlight the selection back but once it end's that subroutine the highlighted selection turns off.  
What is causing this and how do i remedy it?
 
To give you more info i set the listview's property: HideSelection to "FALSE" meaning to maintain its highlighted selection if i somehow loose focus on the listview.
here are my other property selections:

   Begin ComctlLib.ListView ListView1
      Height          =   4335
      Left            =   6480
      TabIndex        =   68
      Top             =   375
      Width           =   2775
      _ExtentX        =   4895
      _ExtentY        =   7646
      View            =   3
      LabelEdit       =   1
      MultiSelect     =   -1  'True
      LabelWrap       =   0   'False
      HideSelection   =   0   'False
      _Version        =   327680
      SmallIcons      =   "ImageList1"
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      Appearance      =   1
      NumItems        =   2
      BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
         Key             =   ""
         Object.Tag             =   ""
         Text            =   "Name"
         Object.Width           =   2117
      EndProperty
      BeginProperty ColumnHeader(2) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
         SubItemIndex    =   1
         Key             =   ""
         Object.Tag             =   ""
         Text            =   "Type"
         Object.Width           =   1676
      EndProperty
   End

Weird huh?  Please help.
0
Comment
Question by:flufgirl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 6

Expert Comment

by:anthonyc
ID: 1458131
Can you show the source that you use to do this task?
0
 
LVL 6

Accepted Solution

by:
anthonyc earned 200 total points
ID: 1458132
Option Explicit
Dim lngHold As Long

Private Sub Command1_Click()
    Dim intI As Integer
   
    For intI = 1 To 10
        Call ListView1.ListItems.Add(intI, , intI)
    Next intI
       
End Sub

Private Sub Command2_Click()
    ListView1.ListItems.Clear

End Sub

Private Sub Command3_Click()
    Dim intI As Integer
   
    For intI = 1 To 10
        Call ListView1.ListItems.Add(intI, , intI)
    Next intI
    Set ListView1.SelectedItem = ListView1.ListItems(lngHold)
End Sub

Private Sub ListView1_Click()
    lngHold = ListView1.SelectedItem.Index
End Sub


This code does what you are sayiing, with proper highlighting!
0
 

Author Comment

by:flufgirl
ID: 1458133
Thanks Anthony but your code works...
And mine still doesnt...go figure....
Your methods are EXACTLY what i implemented into mine originally and i tested your code as a new project and it worked fine.
I also took this portion of the code out of my bigger program and tested it out in a new project and it too works fine, but the weird thing is that it isnt working with the whole program.

I went step by step through the debugger and found that it DOES highlight fine but as soon as it gets to the "End Sub" line it shuts off the highlight.

Are there any programs out there that can trace through your code to see what vb is actually calling (ie. events that i havent put in,etc) or something that i can do to track down what is turning off the highlight?  

PLEASE....i have been looking for 2 months now trying to figure out this error.

Ok, here is what i am trying to do....
I am trying to make it so that if the user double clicks an item in thelistview it will clear the listview and display a new items inside the listview window but following these new items will be the actual selected item.  So instead of storing the index value for the selected item i actually store a "key".
 
So, when the new items are displayed on screen i check up the key value of what was selected and look through this new list and once i find a match i highlight that item.  Makes sense...but the odd thing is that once i do this it does highlight the item but as soon as it goes past the "End Sub" line (finishing the subroutine) the highlight disappears....
 
Is this a BUG in VB 5? or am i doing something wrong?

0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question