Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2014-02-07
3
Medium Priority
?
262 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 45

Accepted Solution

by:
AndyAinscow earned 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

636 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