Solved

How to compare a string list with the text of a listview column.

Posted on 2014-02-07
3
231 Views
Last Modified: 2014-02-11
Hi,

I have a listview where the user can insert a listview row through an input-form. The user can double click on the row then the input-form appears. The user can also select the row be dragging the cursor. To prevent from appearing the input-form twice. I have used a string list to keep track of the input-form that is allready opened by using an unique identifier (the creation date of the input-form) which is stored in column1 I have this for the double click event and it works great:

private List<string> opened = new List<string>();

        private void lvNotes_DoubleClick(object sender, EventArgs e)
        {
            string selectedId = this.lvNotes.SelectedItems[0].SubItems[1].Text(); 
            if (opened.Contains(selectedId)) return;
            OpenSticky(lvNotes.SelectedItems[0]);
        } 

Open in new window


But I don't know how to do this in the event below when the user selects the row(s) by dragging with the cursor and click on the button bbEdtNote it first have to look in the string list if the input form(s) has allready opened. If so then ignore otherwise open them.

        private void bbEdtNote_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (lvNotes.SelectedItems.Count == 0) return;
            foreach (ListViewItem lvi in this.lvNotes.SelectedItems)
            {
                OpenSticky(lvi);
            }
        }

Open in new window


Who knows the answer and is willing to help me?

Greetings,

Peter Kiers
0
Comment
Question by:peterkiers
3 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 39841608
>>I have used a string list to keep track of the input-form that is allready opened by using an unique identifier

As I mentioned in an earlier question I do not think you need to do that.  The application has a collection of all open forms - so you can loop through that collection to check if your input form is currently open.


Back to your question, this is the logic you seem to require:
foreach (ListViewItem lvi in this.lvNotes.SelectedItems)
{
  if (!opened.Contains(selectedId))  //if it is not in the list then open it
    OpenSticky(lvi);
}
0
 
LVL 1

Author Comment

by:peterkiers
ID: 39841653
Oke thanks. Greetings, Peter Kiers
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

746 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now