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 includes a Cancel
button, and if they click Cancel, I'd like to short-circuit the selection of
the other item and keep the user at the one they were editing.
I can't find a way to do this. I've tried trapping the Click event, then the
MouseDown event and the Validating event and none of them seem to give me a
way to prevent the ListView from selecting the new item. I tried
programmitcally unassigning the handler for the SelectedIndexChanged event,
but that just prevents the details for the new item from showing up - the
ListView still selects the new item.
What do I need to do? Thanks. 2 2967
I think you can iterate through the ListView items and set/unset which are
selected:
listview.Items[10].Selected = false;
Here is how the technique is explained in detail: http://msdn.microsoft.com/library/de...ectedtopic.asp
Alex
"David Anderson" <da*******************@tamko.com> wrote in message
news:76**********************************@microsof t.com... 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 includes a Cancel button, and if they click Cancel, I'd like to short-circuit the selection of the other item and keep the user at the one they were editing.
I can't find a way to do this. I've tried trapping the Click event, then the MouseDown event and the Validating event and none of them seem to give me a way to prevent the ListView from selecting the new item. I tried programmitcally unassigning the handler for the SelectedIndexChanged event, but that just prevents the details for the new item from showing up - the ListView still selects the new item.
What do I need to do? Thanks.
Okay, I see how that would restore the previous item, if I keep track of it.
Seems messy, but workable. I'll play with it.
Thanks.
"Alex Passos" wrote: I think you can iterate through the ListView items and set/unset which are selected:
listview.Items[10].Selected = false;
Here is how the technique is explained in detail:
http://msdn.microsoft.com/library/de...ectedtopic.asp
Alex
"David Anderson" <da*******************@tamko.com> wrote in message news:76**********************************@microsof t.com... 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 includes a Cancel button, and if they click Cancel, I'd like to short-circuit the selection of the other item and keep the user at the one they were editing.
I can't find a way to do this. I've tried trapping the Click event, then the MouseDown event and the Validating event and none of them seem to give me a way to prevent the ListView from selecting the new item. I tried programmitcally unassigning the handler for the SelectedIndexChanged event, but that just prevents the details for the new item from showing up - the ListView still selects the new item.
What do I need to do? Thanks. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
...
|
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...
|
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...
|
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.
|
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...
|
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...
|
by: Benny Raymond |
last post by:
I have a list view and a button that turns the currently selected item's
ForeColor to SystemColors.GrayText
The problem I'm having is that when the user clicks in white space, the
item becomes...
|
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
|
by: c35tar1 |
last post by:
I have a ListView within a dialog. In code the groups are created and
items added. Display is 100% correct. The problem is with using
Shift to select multiple items in the list.
- If you...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
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...
|
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...
| |