*Gurus* Derek Stone Posted March 1, 2003 *Gurus* Posted March 1, 2003 Pass a reference of the class (the form/window) instead of creating a new instance. Quote Posting Guidelines
aewarnick Posted March 1, 2003 Author Posted March 1, 2003 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). Quote C#
*Gurus* Derek Stone Posted March 1, 2003 *Gurus* Posted March 1, 2003 We're going to need more specific details. What exactly are you trying to do? A code snippet would help significantly. Quote Posting Guidelines
aewarnick Posted March 1, 2003 Author Posted March 1, 2003 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. Quote C#
*Gurus* Derek Stone Posted March 1, 2003 *Gurus* Posted March 1, 2003 PrintViewForm P; if(Old) { if(P = null) { P = new PrintViewForm(); } // Your code here } Quote Posting Guidelines
aewarnick Posted March 1, 2003 Author Posted March 1, 2003 (edited) 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? Edited March 1, 2003 by aewarnick Quote C#
aewarnick Posted March 1, 2003 Author Posted March 1, 2003 How absent minded of me!!! All I had to do is put PrintViewForm P=null; outside the loop and that solved everything. Quote C#
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.