By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,661 Members | 1,917 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,661 IT Pros & Developers. It's quick & easy.

Selecting other listview item after removing one

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a

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**************@TK2MSFTNGP05.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

P: n/a
Yes, got that, but how do I get it to trigger the click event?

"Dan Bass" <da*****@REMOVEblueCAPSbottle.comwrote in message
news:43**********************************@microsof t.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**************@TK2MSFTNGP05.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

P: n/a
I would do it on the "SelectedIndexChanged" 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**************@TK2MSFTNGP03.phx.gbl...
Yes, got that, but how do I get it to trigger the click event?

"Dan Bass" <da*****@REMOVEblueCAPSbottle.comwrote in message
news:43**********************************@microsof t.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**************@TK2MSFTNGP05.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

P: n/a
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.FocusItem.
So I used that. Clicking an Item loads an image into a picturebox.
So to delete one I use Listview.FocusedItem.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*****@REMOVEblueCAPSbottle.comwrote in message
news:7C**********************************@microsof t.com...
>I would do it on the "SelectedIndexChanged" 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**************@TK2MSFTNGP03.phx.gbl...
>Yes, got that, but how do I get it to trigger the click event?

"Dan Bass" <da*****@REMOVEblueCAPSbottle.comwrote in message
news:43**********************************@microso ft.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**************@TK2MSFTNGP05.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

P: n/a
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**************@TK2MSFTNGP02.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.FocusItem.
So I used that. Clicking an Item loads an image into a picturebox.
So to delete one I use Listview.FocusedItem.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*****@REMOVEblueCAPSbottle.comwrote in message
news:7C**********************************@microsof t.com...
>>I would do it on the "SelectedIndexChanged" 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**************@TK2MSFTNGP03.phx.gbl...
>>Yes, got that, but how do I get it to trigger the click event?

"Dan Bass" <da*****@REMOVEblueCAPSbottle.comwrote in message
news:43**********************************@micros oft.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**************@TK2MSFTNGP05.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 discussion thread is closed

Replies have been disabled for this discussion.