473,382 Members | 1,165 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.

Programmatically selecting a listview item..??

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[0].Selected = true;

Also tried to invalidate and get a redraw, didn't make a
difference...

Thanks for any help.

Vince
Jul 19 '05 #1
3 5170
If you code is correct, I am sure it IS selected. But to visibly show the
selection, the listview must have focus ( add listView4.Focus() following
listView4.Items[0].Selected=true), or ListView.HideSelection property is set
to false (default value is true).

"vince" <vl******@sdcera.org> wrote in message
news:03****************************@phx.gbl...
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[0].Selected = true;

Also tried to invalidate and get a redraw, didn't make a
difference...

Thanks for any help.

Vince

Jul 19 '05 #2
Try listview4.selectedindex = 0

its something along those lines.

"vince" <vl******@sdcera.org> wrote in message
news:03****************************@phx.gbl...
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[0].Selected = true;

Also tried to invalidate and get a redraw, didn't make a
difference...

Thanks for any help.

Vince

Jul 19 '05 #3
thanks, that was it, needed to set focus in addition to
selecting...

-----Original Message-----
If you code is correct, I am sure it IS selected. But to visibly show theselection, the listview must have focus ( add listView4.Focus() followinglistView4.Items[0].Selected=true), or ListView.HideSelection property is setto false (default value is true).

"vince" <vl******@sdcera.org> wrote in message
news:03****************************@phx.gbl...
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[0].Selected = true;

Also tried to invalidate and get a redraw, didn't make a difference...

Thanks for any help.

Vince

.

Jul 19 '05 #4

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

Similar topics

1
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...
3
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... ...
1
by: Bob Geltz | last post by:
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...
4
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
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...
2
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...
5
by: Richard Bond | last post by:
I'm having a lot of trouble programatically selecting a listview item. How do you do this? These didn't work for me in the context of the sub below (that's trying to move up an Item in the...
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...
5
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
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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.