473,396 Members | 1,895 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,396 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 5172
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: 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:
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?
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.