-
Sep 12th, 2024, 02:59 PM
#1
Thread Starter
New Member
[RESOLVED] Help with a ListView Control
Hello,
I am not going to post any code here because my issue isn't with how my code works. I have a form that has a listview control on it that gets populated with words. On the same form, I have a button that allows a user the opportunity to select (highlight) special words contained in the listview. Examples: all of the words starting with "g", all of the words with 5 consonants, all of the words ending in the letter "e"
My code for this works flawlessly. After the code has finished highlighting the words, the form refreshes (focus has been removed and restored) and the listview redraws. This causes the first item in the listview to become "selected" or drawn with a square around it - even if it isn't a selected item! I find this distracting and annoying. Has anyone else had this issue? If so can you please share what you have done to overcome this?
Again I am using VS 2012 (it was free and I cannot afford anything else right now)
-
Sep 13th, 2024, 05:40 AM
#2
Re: Help with a ListView Control
A ListView can have multiple selected items but only one focused item and the two are independent of each other. If you're seeing a focus rectangle around an item it means that the ListView has focus and that is the FocusedItem. You need to either remove focus from the control or the item. You can call Select on another control or assign another control to the ActiveControl property of the form to shift focus, or you can set the ActiveControl to Nothing for no control to have focus. If you want the ListView to retain focus, I think that you can set the FocusedItem to Nothing to remove that focus rectangle.
-
Sep 13th, 2024, 01:06 PM
#3
Thread Starter
New Member
Re: Help with a ListView Control
Originally Posted by jmcilhinney
A ListView can have multiple selected items but only one focused item and the two are independent of each other. If you're seeing a focus rectangle around an item it means that the ListView has focus and that is the FocusedItem. You need to either remove focus from the control or the item. You can call Select on another control or assign another control to the ActiveControl property of the form to shift focus, or you can set the ActiveControl to Nothing for no control to have focus. If you want the ListView to retain focus, I think that you can set the FocusedItem to Nothing to remove that focus rectangle.
Thank you so very much. I will try this. You must remember that if "you" choose to see all of the items selected in a ListView, you must set the ListView to focused. If you do not, none of the selected items will be blue in color. This is what I do immediately after selecting any of the items (words). You are so sincerely appreciated.
-
Sep 13th, 2024, 01:42 PM
#4
Thread Starter
New Member
Re: Help with a ListView Control
Originally Posted by EReaUser2012
Thank you so very much. I will try this. You must remember that if "you" choose to see all of the items selected in a ListView, you must set the ListView to focused. If you do not, none of the selected items will be blue in color. This is what I do immediately after selecting any of the items (words). You are so sincerely appreciated.
jmcilhinney , This works wonderfully!!! It was as easy as telling the listview that the index 0 was not focused. Now I understand what the difference is. You did an excellent job of explaining, you were caring and totally professional.
Thank you ever so much again. If you only knew how many hours I spent changing multiple forms and code to try to understand what was going on. I do not know how to close this issue but it CAN be closed now. YOU ROCK!!!
-
Sep 13th, 2024, 09:40 PM
#5
Re: [RESOLVED] Help with a ListView Control
You can still see the selection in a ListView that doesn't have focus if the HideSelection property is set to False. The colour used to highlight selected items will be less bold when the control doesn't have focus but it will still be visible.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|