Solved

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

Posted on 2014-02-07
3
252 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
[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 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

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
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 …

705 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