?
Solved

Cancelling a remove

Posted on 2006-07-19
5
Medium Priority
?
352 Views
Last Modified: 2010-04-16
I have a list of information stored in a list box.

I have a remove and remove all buttons. I also have a Finish and a Cancel.

What I was looking to do was have cancel revert the changes in the list box.The main example that I can give is when you actually have removed certain elements from the list box. You then decide to click cancel, but it doesnt restore the list box.

Any ideas on how best to handle and implement this?
0
Comment
Question by:directxBOB
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:nickhoggard
ID: 17144002
Hi,

I'm not entirely sure what you are asking for here.  Is the cancel supposed to act as an undo, adding the last removed item back in, or is it supposed to refresh the listbox to its original state?   Also, what sort of objects are being stored in the list box?

Cheers

Nick
0
 

Author Comment

by:directxBOB
ID: 17144133
At the moment the list box is just string objects but I will replace them down the line.

Well I can either take 2 roots, when I remove something I can store it in a cache until finished is clicked Which is ideal, or I can refresh back to the original state. The second method is fine as well. just once data is not lost when canceled.
0
 

Author Comment

by:directxBOB
ID: 17144148
The way I was thinking of doing it was to all the user to select what they want to remove, or to remove all.

Then have flags, if the user hits cancel nothing is done, but if the user hits finished it checks these flags and removes whats been requested.
0
 
LVL 5

Accepted Solution

by:
nickhoggard earned 2000 total points
ID: 17144651
Not sure if this is exactly what you were after, but the only thing I can think of would be to either a) cache a clone of  the whole dataset when you set the DataSource property, b) cache the removed items as discuessed above.  I'd probably go with b) myself.

Something like:

using System;
using System.Collections.Generic;
using System.Text;

namespace WindowsApplication1 {
    class ListBoxEx : ListBox {

        System.Collections.ArrayList cvobjRemovedItems = new System.Collections.ArrayList();
        public void RemoveAt(int intIndex) {
            cvobjRemovedItems.Add(this.Items(intIndex));
            this.Items.RemoveAt(intIndex);
        }

        public void Cancel() {
            foreach (object obj in cvobjRemovedItems) {
                this.Items.Add(obj);
            }
        }

        public void ClearCache() {
            cvobjRemovedItems.Clear();
        }

    }
}

Hope this gets you started.

Cheers

Nick
0
 

Author Comment

by:directxBOB
ID: 17151238
Dumb question but Im doing this:

      foreach (object obj in RemoveList)
      {
        int selectedIndex = RemoveList.????
      }


How do I actually get the value that I am currently on in RemoveList out? I am putting in all selected indexes. so Im really just wondering how I get the values out.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question