Solved

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

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TCP Chat/GPS application security thru firewall 4 54
Convert Silverlight ERP To Angularjs,HTML5 3 107
Adding where clause to entity statement c# 1 61
ModalPopup  question 22 56
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…

734 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