I currently have a parent control (Form1) and a child control (Form2).
Form1 contains a listview that stores a list of of file data (each file is a separate item).
Form2 contains only a textbox.
Upon clicking on one of these listviewitems in Form1, Form2 is opened up and accesses the file’s data and loads it into the textbox in Form2 in plain text format.
The issue I’m having is, I would like to be able to detect, upon clicking of a listviewitem, whether that file is already opened in said child form and if so, to activate it (bring it to the front) and if it is not already opened, open it. I’m not sure what the best method of doing this would be since this can involve many child forms being open at once. This is not an MDI application. Any ideas on how this could be accomplished are appreciated and samples even more so. Thank you.
What I have done in the past is give each new form a unique tag (based on the file you’re viewing in this case), so:
Then, when going to open up a window for a file, iterate over all the open forms checking tags like so:
And this should only open up one form per file (or tag really)
Hopefully that helps !