473,382 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

ListView.Selecteditem

Is there a way to simulate a selection (let's say to the third item on the
list) and cause the highlight to appear?

Any ideas welcomed and appreciated. Thanks!
Feb 3 '06 #1
8 32855
Raoul Watson wrote:
Is there a way to simulate a selection (let's say to the third item on the
list) and cause the highlight to appear?

Any ideas welcomed and appreciated. Thanks!


Set ListView.SelectedItem = ListView.ListItems(2)

--
Dean Earley (de*********@icode.co.uk)
i-Catcher Development Team

iCode Systems
Feb 3 '06 #2
Wow.. that's cool.. Thanks Dean.. it's appreciated!

"Dean Earley" <de*********@icode.co.uk> wrote in message
news:43**********************@news.zen.co.uk...
Raoul Watson wrote:
Is there a way to simulate a selection (let's say to the third item on the list) and cause the highlight to appear?

Any ideas welcomed and appreciated. Thanks!


Set ListView.SelectedItem = ListView.ListItems(2)

--
Dean Earley (de*********@icode.co.uk)
i-Catcher Development Team

iCode Systems

Feb 4 '06 #3
Interesting observation is that eventhough the value of selected item is
corrrect, the item is not highlighted as it would be when one clicks on it.

"Dean Earley" <de*********@icode.co.uk> wrote in message
news:43**********************@news.zen.co.uk...
Raoul Watson wrote:
Is there a way to simulate a selection (let's say to the third item on the list) and cause the highlight to appear?

Any ideas welcomed and appreciated. Thanks!


Set ListView.SelectedItem = ListView.ListItems(2)

--
Dean Earley (de*********@icode.co.uk)
i-Catcher Development Team

iCode Systems

Feb 4 '06 #4

"Raoul Watson" <Wa*****@IntelligenCIA.com> wrote in message
news:kMXEf.58$_I4.1@trndny02...
Interesting observation is that eventhough the value of selected item is
corrrect, the item is not highlighted as it would be when one clicks on it.


If the listview HideSelection property is true, the highlight will not appear
when the listview does not have focus.

You can set this property to false; and/or you can add
ListView1.SetFocus
after changing the selected item.

An alternative to setting the selection would be
ListView1.ListItems(2).Selected = True
Feb 4 '06 #5
That was it .. thanks Steve (sorry for the top post)

"Steve Gerrard" <my********@comcast.net> wrote in message
news:4Z********************@comcast.com...

"Raoul Watson" <Wa*****@IntelligenCIA.com> wrote in message
news:kMXEf.58$_I4.1@trndny02...
Interesting observation is that eventhough the value of selected item is
corrrect, the item is not highlighted as it would be when one clicks on it.
If the listview HideSelection property is true, the highlight will not

appear when the listview does not have focus.

You can set this property to false; and/or you can add
ListView1.SetFocus
after changing the selected item.

An alternative to setting the selection would be
ListView1.ListItems(2).Selected = True

Feb 7 '06 #6
Raoul Watson wrote:
Interesting observation is that eventhough the value of selected item is
corrrect, the item is not highlighted as it would be when one clicks on it.


Erm, yeah, I noticed this the other day.

SelectedItem is the item with the focus rectangle (can NOT be unselected)
Highlighted items (no native property) are items with .Selected = true

When you click an item, it sets both to the item in question, but
clicking an empty area ONLY unhighlights it, but leaves it "selected"

From my experience, setting .SelectedItem does highlight it as well though.

--
Dean Earley (de*********@icode.co.uk)
i-Catcher Development Team

iCode Systems
Feb 7 '06 #7
You can totally deselect the selected item at any time using:

'for single-select controls
If Not ListView1.SelectedItem Is Nothing Then
ListView1.SelectedItem.Selected = False
Set ListView1.SelectedItem = Nothing
End If
'or, for multi-select controls
Dim itmx As ListItem

If Not ListView1.SelectedItem Is Nothing Then

For Each itmx In ListView1.ListItems
itmx.Selected = False
Next

End If
--

Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/

Please reply to the newsgroups so all can participate.


"Dean Earley" <de*********@icode.co.uk> wrote in message
news:43***********************@news.zen.co.uk...
: Raoul Watson wrote:
: > Interesting observation is that eventhough the value of selected item is
: > corrrect, the item is not highlighted as it would be when one clicks on
it.
:
: Erm, yeah, I noticed this the other day.
:
: SelectedItem is the item with the focus rectangle (can NOT be unselected)
: Highlighted items (no native property) are items with .Selected = true
:
: When you click an item, it sets both to the item in question, but
: clicking an empty area ONLY unhighlights it, but leaves it "selected"
:
: From my experience, setting .SelectedItem does highlight it as well
though.
:
: --
: Dean Earley (de*********@icode.co.uk)
: i-Catcher Development Team
:
: iCode Systems

Feb 9 '06 #8
Randy Birch wrote:
You can totally deselect the selected item at any time using:

'for single-select controls
If Not ListView1.SelectedItem Is Nothing Then
ListView1.SelectedItem.Selected = False
Set ListView1.SelectedItem = Nothing
End If


Sorry, I meant the user can't deselect it using the standard listview.

--
Dean Earley (de*********@icode.co.uk)
i-Catcher Development Team

iCode Systems
Feb 9 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Eva | last post by:
Hi, I wanted to know how i can enter values into a specific column of a listview. I have tried the following code but this seems to enter all my values into the first column!!! Can anyone...
1
by: Liz | last post by:
I have used a ListView with several columns and lines to display an array ListView1.Items.Clear(); ListView1.Items.Add(aClients.Id); ListView1.Items.Add(aClients.Id); ...
1
by: youngie | last post by:
I've got a listview on a form in report style. It's populated with 40 item. I want to prevent the used clicking on some items, and if the user clicks on one of these items I want the selection to...
7
by: Visual Systems AB \(Martin Arvidsson\) | last post by:
Hi! I'v been struggeling with removing selected items from a listview. Anyone that can give me a piece of code that does this? I am a newbee to this C# and cant figure it out.... Regards...
3
by: larry mckay | last post by:
anyone have the code to select and listview item or row (subitems) after a doubleclick event from a listview. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate...
2
by: amber | last post by:
Hello I have a listview that displays a list of choices When the mouse moves over each item, I would like text (the name of the item that is being hovered over) to show u in a seperate label or...
4
by: firefox | last post by:
Hola Foro!, tengo una rutina que permite agregar varios elementos o items de una sola vez en un ListView. Lo que sucede es que en el momento que se añaden los items al ListView se pone todo blanco,...
3
by: kenny.deneef | last post by:
Hey, I'm searching for a methode to get the the reference to an object I added into a listview. I got this class Address class Address { private string street; private string numb;
11
by: MarkTingson | last post by:
I am creating a VB6 project that uses listview as my datagrid. So far I am successful in adding, editing, deleting and refreshing the table (I'm talking about the listview). My problem now is to do...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.