Stopping new windows from being made when one just like it is already made

I do not know what you mean. Can you give an example.

I also need to have a way to test and see if the form is open or not (bool method probably).
 
I have a form with textboxes that will only hold text without @Old at the end of the file. If a file does have @Old at the end it goes to the Rich Text Box of the PrintView form easy printing.

if(Old)
{
PrintViewForm P=new PrintViewForm();
P.GetItFromFile(file);
P.Show();
}

The problem is that it is in a loop and need to be in a loop to work correctly. So, I need one to initially be created and all others to append to the text in that same one.

The loop circles again and again so I cannot just put the initialization outside the loop I need to learn how to reference a form and how to check if one is already open or not.
 
It would not compile like this:

if(Old)
{
PrintViewForm P;
if(P==null)
{
P=new PrintViewForm();
P.GetItFromFile(FileArr[k]);
P.Show();
}
else P.GetItFromFile(FileArr[k]);

Says, use of unassigned local variable P and when I assigned P to null it compiles but a whole bunch of forms pop up like before.

I have an idea, maybe I can do a search for the PrintViewForm type. But how?
 
Last edited:
How absent minded of me!!! All I had to do is put PrintViewForm P=null; outside the loop and that solved everything.
 
Back
Top