473,386 Members | 1,860 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,386 software developers and data experts.

ListViews Setting the selected Item How???

In a list box, lbox1.SetSelected(0, True) or lbox1.SelectedIndex = 0 all
work fine but how do you set the selected line in a ListView, is it
possible?

The ListView is being used in Details-View mode, in each line the first item
is a line No. (1 - 150 in this instance). I can get an index no for a line I
select with the mouse but cannot find a way to programatically select a line
(Specifically, for example, either select item 10 or ListView index 9).

Also In association with this I need to be able to use the up and down
keyboard arrows to move the selected line up and down. I assume the answer
to the first part will answer the second part but is there yet another twist
I need to know??

Bob
Nov 21 '05 #1
2 1609
On Tue, 31 Aug 2004 07:48:04 +0100, "StriderBob"
<rw**@mdbatisisps.freeserve.co.uk> wrote:
In a list box, lbox1.SetSelected(0, True) or lbox1.SelectedIndex = 0 all
work fine but how do you set the selected line in a ListView, is it
possible?

The ListView is being used in Details-View mode, in each line the first item
is a line No. (1 - 150 in this instance). I can get an index no for a line I
select with the mouse but cannot find a way to programatically select a line
(Specifically, for example, either select item 10 or ListView index 9).

Also In association with this I need to be able to use the up and down
keyboard arrows to move the selected line up and down. I assume the answer
to the first part will answer the second part but is there yet another twist
I need to know??


Hi Bob,

try listview.Items(index).Selected = True

Steve

Nov 21 '05 #2

"Steve Cutting" <sc******@optusnet.com.au> wrote in message
news:0k********************************@4ax.com...
On Tue, 31 Aug 2004 07:48:04 +0100, "StriderBob"
<rw**@mdbatisisps.freeserve.co.uk> wrote:
In a list box, lbox1.SetSelected(0, True) or lbox1.SelectedIndex = 0 all
work fine but how do you set the selected line in a ListView, is it
possible?

The ListView is being used in Details-View mode, in each line the first
item
is a line No. (1 - 150 in this instance). I can get an index no for a line
I
select with the mouse but cannot find a way to programatically select a
line
(Specifically, for example, either select item 10 or ListView index 9).

Also In association with this I need to be able to use the up and down
keyboard arrows to move the selected line up and down. I assume the answer
to the first part will answer the second part but is there yet another
twist
I need to know??


Hi Bob,

try listview.Items(index).Selected = True

Steve


Thanks Steve, I think !!

Your suggestion works fine in my small test program but when I copy the
whole contents to the child form in my main program it does not. I can see
several days of wonderful MS inspired fun ahead finding out what is the next
question I will need an answer to.

By the way, I cannot find any reference to your solution in the help index
for ListViews. Awesome!!

Bob

Nov 21 '05 #3

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

Similar topics

0
by: kamaumalone | last post by:
I have a dropdownlist which lives inside of a repeater. The repeater accepts user input via textboxes and the aforementioned dropdownlist. The repeater accepts phone numbers and allows for an...
4
by: Emil | last post by:
Can somebody tell me what would be the syntax for having an if statement and setting the selected index of a radiobuttonlist? This is my first project using ASP.net and I use C#. I have a repeater...
3
by: tshad | last post by:
Is there a way to stop the system from setting the SelectedIndex of a dropdownlist to 0? I have it set at -1 in my code and if I push a button (that does nothing in my test), during PostBack it...
8
by: VB User | last post by:
I would like the text property of combo box to read the first item of the list on form load. I have a set of four items in the collection. How do I do it? Thanks
4
by: Waqas101 | last post by:
Hi, I have a question regarding the creation of multiple listviews during run-time. I currently have code that uses a loop to create 5 listviews with identical properties (excep for the name)....
0
by: Eirik Eldorsen | last post by:
I can't figure out how to set that an level1 and level2 item is selected at the same time. Is this not possible? Here is my code that set selected item: private void UpdateMenu() { foreach...
3
by: Michael.Suarez | last post by:
I have 1 contextmenu with several buttons. two different listviews sit beside each other on the same form. Both use the same context menu. I have a method for when a menu item gets clicked: ...
18
by: Academia | last post by:
I let the use modify the text of a combobox and then I replace the selected item with the new text (in Keyup event). But if he sets the Text property to an empty string ("") that sets the...
0
by: waldedg | last post by:
I have a ListBox set as Multiselect. I am populating the table thruough asp.net code. But I am using another dataset to get the items that should be selected. The only item that ends up selected is...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.