473,606 Members | 2,877 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Selecting other listview item after removing one

Hi,

What's the best way to programmaticly select (click) another listview Item
after removing the selected/focused one.

using VB2005 Express.

Thanks
Bart
Dec 5 '07 #1
5 2536

Typically...
- Get the index of the selected item and store in a local integer.
- The remove the selected item
- Now check to see that the selected item's index is less than the max index
(list count -1). (I.E. did you just remove the last item in the menu)
- If the index is still valid, select this item otherwise select the last
item in the list.
"Bart Steur" <so*****@xs4all .nlwrote in message
news:ee******** ******@TK2MSFTN GP05.phx.gbl...
Hi,

What's the best way to programmaticly select (click) another listview Item
after removing the selected/focused one.

using VB2005 Express.

Thanks
Bart
Dec 5 '07 #2
Yes, got that, but how do I get it to trigger the click event?

"Dan Bass" <da*****@REMOVE blueCAPSbottle. comwrote in message
news:43******** *************** ***********@mic rosoft.com...
>
Typically...
- Get the index of the selected item and store in a local integer.
- The remove the selected item
- Now check to see that the selected item's index is less than the max
index (list count -1). (I.E. did you just remove the last item in the
menu)
- If the index is still valid, select this item otherwise select the last
item in the list.
"Bart Steur" <so*****@xs4all .nlwrote in message
news:ee******** ******@TK2MSFTN GP05.phx.gbl...
>Hi,

What's the best way to programmaticly select (click) another listview
Item after removing the selected/focused one.

using VB2005 Express.

Thanks
Bart

Dec 6 '07 #3
I would do it on the "SelectedIndexC hanged" event.
In Visual Studio, if you click on the list, then in the properties window,
click on the little lightening bolt, this shows you what events you
currently have configured. To create one, find the event and double click on
it. This will create a new event in the code.

Alternatively, to do it manually. In the constructor of the form, you can
reference the list promatically (provided it's already been created) and
find the event in there and specify a target event handler method to handle
that event.

Hope that helps.

"Bart Steur" <so*****@xs4all .nlwrote in message
news:ee******** ******@TK2MSFTN GP03.phx.gbl...
Yes, got that, but how do I get it to trigger the click event?

"Dan Bass" <da*****@REMOVE blueCAPSbottle. comwrote in message
news:43******** *************** ***********@mic rosoft.com...
>>
Typically...
- Get the index of the selected item and store in a local integer.
- The remove the selected item
- Now check to see that the selected item's index is less than the max
index (list count -1). (I.E. did you just remove the last item in the
menu)
- If the index is still valid, select this item otherwise select the last
item in the list.
"Bart Steur" <so*****@xs4all .nlwrote in message
news:ee******* *******@TK2MSFT NGP05.phx.gbl.. .
>>Hi,

What's the best way to programmaticly select (click) another listview
Item after removing the selected/focused one.

using VB2005 Express.

Thanks
Bart

Dec 6 '07 #4
I don't think I understand your solution.

I'm used to VB6 (For almost a decade). There you had the ItemClick Event
which supplied the Item that was clicked. Now online help suggests to use
the Click event in combination with Listview.FocusI tem.
So I used that. Clicking an Item loads an image into a picturebox.
So to delete one I use Listview.Focuse dItem.Remove. Now after deleting I
want to programmaticly click the preceding item in the list. So the
Click_event coding is triggered and the image is shown.

Thanks
Bart
"Dan Bass" <da*****@REMOVE blueCAPSbottle. comwrote in message
news:7C******** *************** ***********@mic rosoft.com...
>I would do it on the "SelectedIndexC hanged" event.
In Visual Studio, if you click on the list, then in the properties window,
click on the little lightening bolt, this shows you what events you
currently have configured. To create one, find the event and double click
on it. This will create a new event in the code.

Alternatively, to do it manually. In the constructor of the form, you can
reference the list promatically (provided it's already been created) and
find the event in there and specify a target event handler method to
handle that event.

Hope that helps.

"Bart Steur" <so*****@xs4all .nlwrote in message
news:ee******** ******@TK2MSFTN GP03.phx.gbl...
>Yes, got that, but how do I get it to trigger the click event?

"Dan Bass" <da*****@REMOVE blueCAPSbottle. comwrote in message
news:43******* *************** ************@mi crosoft.com...
>>>
Typically.. .
- Get the index of the selected item and store in a local integer.
- The remove the selected item
- Now check to see that the selected item's index is less than the max
index (list count -1). (I.E. did you just remove the last item in the
menu)
- If the index is still valid, select this item otherwise select the
last item in the list.
"Bart Steur" <so*****@xs4all .nlwrote in message
news:ee****** ********@TK2MSF TNGP05.phx.gbl. ..
Hi,

What's the best way to programmaticly select (click) another listview
Item after removing the selected/focused one.

using VB2005 Express.

Thanks
Bart



Dec 7 '07 #5
Bart,

You want to select an item and have it display the picture in the listview,
which I believe you have at the moment?
Now you want to remove this item (presumably with some delete button press)
and have another item selected, and in doing so have the picture for that
list item displayed?
What version of Visual Studio are you using?

If this is not what you are doing, please first describe this, then maybe
we'll be able to help.

Thanks.
Daniel.

"Bart Steur" <so*****@xs4all .nlwrote in message
news:e9******** ******@TK2MSFTN GP02.phx.gbl...
>I don't think I understand your solution.

I'm used to VB6 (For almost a decade). There you had the ItemClick Event
which supplied the Item that was clicked. Now online help suggests to use
the Click event in combination with Listview.FocusI tem.
So I used that. Clicking an Item loads an image into a picturebox.
So to delete one I use Listview.Focuse dItem.Remove. Now after deleting I
want to programmaticly click the preceding item in the list. So the
Click_event coding is triggered and the image is shown.

Thanks
Bart
"Dan Bass" <da*****@REMOVE blueCAPSbottle. comwrote in message
news:7C******** *************** ***********@mic rosoft.com...
>>I would do it on the "SelectedIndexC hanged" event.
In Visual Studio, if you click on the list, then in the properties
window, click on the little lightening bolt, this shows you what events
you currently have configured. To create one, find the event and double
click on it. This will create a new event in the code.

Alternativel y, to do it manually. In the constructor of the form, you can
reference the list promatically (provided it's already been created) and
find the event in there and specify a target event handler method to
handle that event.

Hope that helps.

"Bart Steur" <so*****@xs4all .nlwrote in message
news:ee******* *******@TK2MSFT NGP03.phx.gbl.. .
>>Yes, got that, but how do I get it to trigger the click event?

"Dan Bass" <da*****@REMOVE blueCAPSbottle. comwrote in message
news:43****** *************** *************@m icrosoft.com...

Typically. ..
- Get the index of the selected item and store in a local integer.
- The remove the selected item
- Now check to see that the selected item's index is less than the max
index (list count -1). (I.E. did you just remove the last item in the
menu)
- If the index is still valid, select this item otherwise select the
last item in the list.
"Bart Steur" <so*****@xs4all .nlwrote in message
news:ee***** *********@TK2MS FTNGP05.phx.gbl ...
Hi,
>
What's the best way to programmaticly select (click) another listview
Item after removing the selected/focused one.
>
using VB2005 Express.
>
Thanks
Bart
>

Dec 7 '07 #6

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

Similar topics

3
5191
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
2048
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.
1
3396
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 way, if a user clicks on the OK button, there will be a default selection. I know how to use ListView.SelectedItems 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...
2
2990
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...
7
34778
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 Martin Arvidsson
2
3698
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
15711
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!
3
2146
by: Matt Michael | last post by:
I have a listview control and a collection object right now that I'm trying to pass information to and from. Whenever I click on the checkbox, I want it to remove certain listview items and add them to the collection. Whenever I uncheck the checkbox, I want to add the items back into the listview from the collection, and remove them from the collection so I can do the process multiple times. The listview tag is being used as a key, so I...
5
10073
by: Phill W. | last post by:
(VB'2003) What's the correct way to remove multiple, selected items from a ListView control (say, from a ContextMenu)? I ask because I'm getting a very annoying ArgumentOutOfRangeException because the ListView seems to be trying to "re-select" items that are no longer there! for example, giventhat I have 3 items in my list: Select the first and remove it - no problem.
0
8443
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8107
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
8315
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...
0
6792
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5971
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
5467
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3945
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
3989
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.