473,830 Members | 2,062 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pre Selecting an item in ListView?

I am able to populate a ListView with several detail lines (several
columns). When finished, I would like to pre-select the first item in the
list (before the user interacts with the list). This way, if a user clicks
on the OK button, there will be a default selection.

I know how to use ListView.Select edItems to get the selection,
I just don't know how to make an item be selected without the
user actually clicking on a line.

For a ListBox, I could use ListBox.SetSele cted (0, true). I am looking
for an equivalent function for ListView.

Any suggestions? This has to be a trivial problem, but I cannot find
anything in the documentation that tells me what property to set (or how to
set it)

Thanks..

Nov 15 '05 #1
1 3410
Hi Bob,

The items in a listview are a collection of
listviewitems. They can be accessed individually by
specifying which item you want to change, like this:

lsvTest.Items[0].Selected = true;

where the index if Items is the index of the item in the
list. So this code will select the first item in the
list.

Doug
-----Original Message-----
I am able to populate a ListView with several detail lines (severalcolumns). When finished, I would like to pre-select the first item in thelist (before the user interacts with the list). This way, if a user clickson the OK button, there will be a default selection.

I know how to use ListView.Select edItems to get the selection,I just don't know how to make an item be selected without theuser actually clicking on a line.

For a ListBox, I could use ListBox.SetSele cted (0, true). I am lookingfor an equivalent function for ListView.

Any suggestions? This has to be a trivial problem, but I cannot findanything in the documentation that tells me what property to set (or how toset it)

Thanks..

.

Nov 15 '05 #2

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

Similar topics

3
5208
by: vince | last post by:
I need to programmatically select the first item in a listview before the listview is displayed, so far I'm not having any luck. Here's what I tried in the init for the listview... LoadListView(); listView4.Items.Selected = true; Also tried to invalidate and get a redraw, didn't make a difference...
1
2060
by: Sean Chapman | last post by:
I was wondering how I would go about programmincally selecting a listView item in a listView since the Selected val is read-only. I can't seem to find any other method that will do this for me. I'm using a listView to list some items and want to be able to delete one, then have it select the next one in the list automatically.
4
9717
by: Paddy | last post by:
How do I select a subitem from a listview after clicking on the first column? Couldn't find it in MSDN. Thank you. Paddy.
2
3006
by: David Anderson | last post by:
I'm working on a Windows app that has a ListView containing a bunch of items. When the user clicks on an item, the app displays the item'd details. The user then has the opportunity to edit these details. The user should click the Save button after each change, but of course that doesn't always happen. If the user makes changes and doesn't click Save, the app displays a message box asking if they'd like to save their changes. This box...
3
15722
by: Bry | last post by:
I know you can select a single item in a list view using the following code listView.Items.Selected = true; Is it possible to do this for all items in the listView control without using a loop? Thanks.
2
3715
by: Fritz | last post by:
I know it, I know it. It's come up a lot. I've done the Googling, but the standard answer doesn't do what I expect it to. For the record, the standard answer is: "Set the Selected property of a ListViewItem to true." I also know from MSDN that the selection won't really take effect until the ListView has focus. My specific problem is that setting item.Select = true doesn't actually select my item (or at least, doesn't highlight it). I'm...
3
15724
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 in USENET...get rewarded for it!
5
2559
by: Bart Steur | last post by:
Hi, What's the best way to programmaticly select (click) another listview Item after removing the selected/focused one. using VB2005 Express. Thanks Bart
1
2080
by: c35tar1 | last post by:
I have a ListView within a dialog. In code the groups are created and items added. Display is 100% correct. The problem is with using Shift to select multiple items in the list. - If you select the first item and then a second next to it, it reverses the selection - If you select the first item and then Shift to a few further down or across groups it selects all but reverses the initial item This behavior doesn't occur when the...
0
9781
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9641
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10522
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10197
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7740
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5615
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5777
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3956
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3072
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.