I have a ListView that populates some fields whenever the user selects an item. However, if they change the data in the fields and then select a new item without saving, I want to display a message box that warns that their changes will be lost, and asks them to confirm whether to continue. Sounds simple
Unfortunately, the ListView's SelectedIndexCh anged event cannot be cancelled, and it's actually called for each change in the selection. So, for example, if item 1 is selected and the user then selects item 2, the event is called twice: once to remove the selection of item 1, and then to add the selection of item 2. If you go from having one item selected to having five (for example), the event fires to remove your original selection, and then again for each of your new selections - six hits in all
Obviously, this makes it a pain to determine when the event should be cancelled and reset back to the original. I obviously don't want my message box appearing six times....
Does anyone have a workaround for this
Thanks.. 8 6326
Hi Invisible
The selectionIndexC hange event is the default however it is not said that
you should use it.
There is also the click event, the columnclick, mouseup, why not try one of
those.
I hope this helps?
Cor
Hi Invisible
The selectionIndexC hange event is the default however it is not said that
you should use it.
There is also the click event, the columnclick, mouseup, why not try one of
those.
I hope this helps?
Cor
Hi Invisible,
I forgot, for this kind of questions are also newsgroups as
microsoft.publi c.dotnet.langua ges.vb and csharp (also for C++ and J#)
There are also special control newsgroups, however to that you can add as
crosspost, but they are in my opinion as dead as a newsgroup dead can be.
Cor
Hi Invisible,
I forgot, for this kind of questions are also newsgroups as
microsoft.publi c.dotnet.langua ges.vb and csharp (also for C++ and J#)
There are also special control newsgroups, however to that you can add as
crosspost, but they are in my opinion as dead as a newsgroup dead can be.
Cor
Thanks for the help, Cor. Unfortunately, those events don't trap movements using the arrow keys, so I'd need to repeat everything in the KeyUp event too. It's worth considering, though
I'll try posting on that other group you mentioned; see if anyone there has any other idea
Duncan
Thanks for the help, Cor. Unfortunately, those events don't trap movements using the arrow keys, so I'd need to repeat everything in the KeyUp event too. It's worth considering, though
I'll try posting on that other group you mentioned; see if anyone there has any other idea
Duncan
Hi Invisible,
You can flag when data is changed. Display the message in
SelectedIndexCh anged event only if this flag is true. After returning from
the message box, if you are not cancelling the event, set this flag to
false. Thus for subsequent firings of this event since this flag is false,
you will not be displaying the message box.
ThanQ...
"InvisibleDunca n" <an*******@disc ussions.microso ft.com> wrote in message
news:87******** *************** ***********@mic rosoft.com... I have a ListView that populates some fields whenever the user selects an
item. However, if they change the data in the fields and then select a new
item without saving, I want to display a message box that warns that their
changes will be lost, and asks them to confirm whether to continue. Sounds
simple. Unfortunately, the ListView's SelectedIndexCh anged event cannot be
cancelled, and it's actually called for each change in the selection. So,
for example, if item 1 is selected and the user then selects item 2, the
event is called twice: once to remove the selection of item 1, and then to
add the selection of item 2. If you go from having one item selected to
having five (for example), the event fires to remove your original
selection, and then again for each of your new selections - six hits in all. Obviously, this makes it a pain to determine when the event should be
cancelled and reset back to the original. I obviously don't want my message
box appearing six times.... Does anyone have a workaround for this?
Thanks...
Hi Invisible,
You can flag when data is changed. Display the message in
SelectedIndexCh anged event only if this flag is true. After returning from
the message box, if you are not cancelling the event, set this flag to
false. Thus for subsequent firings of this event since this flag is false,
you will not be displaying the message box.
ThanQ...
"InvisibleDunca n" <an*******@disc ussions.microso ft.com> wrote in message
news:87******** *************** ***********@mic rosoft.com... I have a ListView that populates some fields whenever the user selects an
item. However, if they change the data in the fields and then select a new
item without saving, I want to display a message box that warns that their
changes will be lost, and asks them to confirm whether to continue. Sounds
simple. Unfortunately, the ListView's SelectedIndexCh anged event cannot be
cancelled, and it's actually called for each change in the selection. So,
for example, if item 1 is selected and the user then selects item 2, the
event is called twice: once to remove the selection of item 1, and then to
add the selection of item 2. If you go from having one item selected to
having five (for example), the event fires to remove your original
selection, and then again for each of your new selections - six hits in all. Obviously, this makes it a pain to determine when the event should be
cancelled and reset back to the original. I obviously don't want my message
box appearing six times.... Does anyone have a workaround for this?
Thanks...
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: InvisibleDuncan |
last post by:
I have a ListView that populates some fields whenever the user selects an item. However, if they change the data in the fields and then select a new item without saving, I want to display a message box that warns that their changes will be lost, and asks them to confirm whether to continue. Sounds simple
Unfortunately, the ListView's...
|
by: LV |
last post by:
Hello,
When I manually set a list view item to be a selected item, the SelectedIndexChanged event is not firing. Am I missing something here?
using System;
using System.Windows.Forms;
namespace DOMBuilder.GUI
{
public delegate void SelectedDomainObjectChangedHandler();
|
by: sandman |
last post by:
I've got a combo box that has an event handler set for
SelectedIndexChanged event. The problem is that it's
firing at startup when I load data from the Form_OnLoad
event. I tried setting a flag at startup and turning it
off at the end of the OnLoad function but the
SelectedIndexChange event gets called after OnLoad
finishes, so my flag is...
|
by: PeacError |
last post by:
Using Microsoft Visual Studio .NET 2003, Visual C# .NET 1.1:
I apologize if this question has been addressed elsewhere, but I could not
find a reference to it in the search engine for this board.
I have a form that contains a ListView and a GroupBox control. The GroupBox
control itself contains several TextBox Controls. I have...
|
by: J055 |
last post by:
Hi
I have a dropdown control which is constructed in another dropdown control
SelectedIndexChanged event
protected void ddlParamType_SelectedIndexChanged(object sender, EventArgs e)
{
// some other code
DropDownList ddlGroups = new DropDownList();
ddlGroups.SelectedIndexChanged += new
| |
by: tbrown |
last post by:
I have a combobox with items like this: {one,two,three}. The selected
index is 0, so "one" appears in the combobox text. When the user drops
down the list, and selects "two", for example, I modify the Items
collection to be {two,one,three} and now want "two" to appear in the
combobox text. However, the combobox text is now blank. the is...
|
by: BillCo |
last post by:
I'm a C# Newbie, so if I've missed the obvious here go easy!!!
I have a form opened from a MDI parent. The form has a data bound
combo box, with a SelectedIndexChanged event (fills a list view box on
the same form depending on selection). It all works fine except when
you close either the form itself or it's MDI parent. Somehow as the
form...
|
by: ArunDhaJ |
last post by:
Hi Friends,
I'm using .Net1.1.
The SelectedIndexChanged event is generated twice when i change the
selection. I think this is because the event is triggered when an
item
loses focus and the other item gains focus.
I want this event to be triggered only once.
|
by: David Jackson |
last post by:
Hello,
I'm using VS.NET 2005.
I have a ListView populated with data pulled from a SQL Server database.
I have wired up a SelectedIndexChanged event, but I can't find any way of
retrieving the value of the previously selected record.
For example, if the ListView looks like this:
|
by: Tom Bean |
last post by:
I am trying to display a ContextMenuStrip when a user right-clicks on an
item in a ListView and have encountered a something that seems strange to
me.
When the ListView is initially populated, no items are selected. When the
first item is selected by clicking either the left or right button, the
SelectedIndexChanged event fires but not the...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |