|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
how to activated a closed form?the form provides some reference information for me to input information in the parent form, so i don't want to use ShowDialog. besides, i want the form to opened once only how can i do this? i use form1 frmReference; if (frmReference == null) { frmReference = new form1(); } frmReference.Show(); I can successfully control a form to be opened once only but when i close the form, and press the button again... there is error encountered.... thanks! My guess, without checking (late, lazy, sorry), and assuming frmReference is
global, is that the form is disposed whilst closing so you have a reference in your parent wich is not null but the child form is gone (handles freed, memory in garbage, etc ...). Why not pass a parent reference to the child form and when the child closes down it notifies its parent of it's closure, where the parent resets the child reference to null (so it can be reconstructed with your button click) ? AinO. PS. Specifying the error message does wonders (i was not very specific myself, i know so 1-1). Show quoteHide quote "ywchan" <ywc***@gmail.com> wrote in message news:eyUshRXYFHA.3164@TK2MSFTNGP12.phx.gbl... > when i press a button, a form.Show is triggered > the form provides some reference information for me to input information in > the parent form, so i don't want to use ShowDialog. > besides, i want the form to opened once only > > how can i do this? > > i use > form1 frmReference; > if (frmReference == null) > { > frmReference = new form1(); > } > frmReference.Show(); > > I can successfully control a form to be opened once only > but when i close the form, and press the button again... > there is error encountered.... > > thanks! > > ywchan wrote:
Show quoteHide quote > when i press a button, a form.Show is triggered Handle the disposed event of your form and set your reference to null in > the form provides some reference information for me to input information in > the parent form, so i don't want to use ShowDialog. > besides, i want the form to opened once only > > how can i do this? > > i use > form1 frmReference; > if (frmReference == null) > { > frmReference = new form1(); > } > frmReference.Show(); > > I can successfully control a form to be opened once only > but when i close the form, and press the button again... > there is error encountered.... > > thanks! > > this event. Cheers JB if(PropertiesForm == null) { PropertiesForm = new frmProperties(); PropertiesForm.Disposed += new EventHandler(PropertiesForm_Disposed); } if(!PropertiesForm.Visible) { PropertiesForm.Show(); }
Other interesting topics
decompiled .net or VB6?
ComboBox - Searching the List Box Assignment Method C# messaging Nasty bug in the C# compiler, it truncates values on the stack Why enums can convert to IntPtr? Help with Type.InvokeMember in C# Miss out parameter Packaging and distributing my dll SQL string does not recognize querystrings in c# |
|||||||||||||||||||||||