473,832 Members | 2,106 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 2559

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
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.
1
3411
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
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...
7
34805
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
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!
3
2158
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
10091
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
9795
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
9642
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,...
0
10781
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10499
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...
0
10212
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
9320
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...
0
6951
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();...
1
4421
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3972
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.