Which Event is Fire !
-
hi ! i have two project in one solution , form1 from project 1 is running and i m calling from this to prject2 form 2 like that project2.form2 f = new project2.form2(); f.show(); on the buton of form1 call this and form is opening succesfully but when i closed the form2 then its back to form 1 , becouse form 1 is already opend then my question is that which event is fire when i got back to form1 , i checked Activated event is not working may b cumming from other project , may what is differnce b/w show and showdailogue() , when i call like f.showdailogue() ; then its just open and closed automatically . Further Detail : i have a image on form1 i move this image to form2 and edit that image and then save and when i return back to form1 then its should automatically update but its not updated , when i found the event then on that event in form1 i just reload the image to given path .
-
hi ! i have two project in one solution , form1 from project 1 is running and i m calling from this to prject2 form 2 like that project2.form2 f = new project2.form2(); f.show(); on the buton of form1 call this and form is opening succesfully but when i closed the form2 then its back to form 1 , becouse form 1 is already opend then my question is that which event is fire when i got back to form1 , i checked Activated event is not working may b cumming from other project , may what is differnce b/w show and showdailogue() , when i call like f.showdailogue() ; then its just open and closed automatically . Further Detail : i have a image on form1 i move this image to form2 and edit that image and then save and when i return back to form1 then its should automatically update but its not updated , when i found the event then on that event in form1 i just reload the image to given path .
You should have to code on FormClosing event of form2 to notify your form1 that form2 is closed and than... on recieving notification u can reload your image.
-
You should have to code on FormClosing event of form2 to notify your form1 that form2 is closed and than... on recieving notification u can reload your image.
yah i coded to on form closing event or form2 but still when i come to form1 then there is no difference in form1 picturebox control i coded like this on form2 closed event project1.form1 g = new project1.form1(); g.picturebox.Image = null; g.picturebox.Image = Image.FromFile(@"C:\Temp\Temp2.jpg"); g.picturebox.Refresh(); but after this coded still no differnce in form1 picture box , but when i came to form1 then i made here update button when i pressed it then its update on update button i coded g.picturebox.Image = Image.FromFile(@"C:\Temp\Temp2.jpg"); g.picturebox.Refresh(); but i want its directly update and refresh image when i closed form2 and come to form1 .
-
yah i coded to on form closing event or form2 but still when i come to form1 then there is no difference in form1 picturebox control i coded like this on form2 closed event project1.form1 g = new project1.form1(); g.picturebox.Image = null; g.picturebox.Image = Image.FromFile(@"C:\Temp\Temp2.jpg"); g.picturebox.Refresh(); but after this coded still no differnce in form1 picture box , but when i came to form1 then i made here update button when i pressed it then its update on update button i coded g.picturebox.Image = Image.FromFile(@"C:\Temp\Temp2.jpg"); g.picturebox.Refresh(); but i want its directly update and refresh image when i closed form2 and come to form1 .
nomi wrote:
but after this coded still no differnce in form1 picture box
Yes, there is, but you can't see it. You have created a new instance of form1, in which you are changing the picture box. If you want to change the picture box in the existing instance of form1, you need a reference to it in form2. Add a private variable of the type form1 to form2, and a parameter in the constructor of form2 of the type form1. Send a reference to form1 (Me) when you create the form2 instance, and in the constructor you store that in the private variable.
Despite everything, the person most likely to be fooling you next is yourself.
-
nomi wrote:
but after this coded still no differnce in form1 picture box
Yes, there is, but you can't see it. You have created a new instance of form1, in which you are changing the picture box. If you want to change the picture box in the existing instance of form1, you need a reference to it in form2. Add a private variable of the type form1 to form2, and a parameter in the constructor of form2 of the type form1. Send a reference to form1 (Me) when you create the form2 instance, and in the constructor you store that in the private variable.
Despite everything, the person most likely to be fooling you next is yourself.
-
yah i coded to on form closing event or form2 but still when i come to form1 then there is no difference in form1 picturebox control i coded like this on form2 closed event project1.form1 g = new project1.form1(); g.picturebox.Image = null; g.picturebox.Image = Image.FromFile(@"C:\Temp\Temp2.jpg"); g.picturebox.Refresh(); but after this coded still no differnce in form1 picture box , but when i came to form1 then i made here update button when i pressed it then its update on update button i coded g.picturebox.Image = Image.FromFile(@"C:\Temp\Temp2.jpg"); g.picturebox.Refresh(); but i want its directly update and refresh image when i closed form2 and come to form1 .
The reason it's not updating bcz u r making a new instance.. on formclosing event but u need the already open instance.
-
The reason it's not updating bcz u r making a new instance.. on formclosing event but u need the already open instance.
-
mery dost i didnt i just make the object of the from and just giving the path again of the image when form2 is closed then form1 is already opened i dont do anything from form2 like this , form1.show() etc
you need to see your code again... u r creating a new instance of form1 instead of working with the instance in which u r expecting to see the change.
-
you need to see your code again... u r creating a new instance of form1 instead of working with the instance in which u r expecting to see the change.
here is the code on project 2 form2 closed event : CC13 is my frist project and i want to send image or update image in frmedit now tell me plz whats the problem image still not update: protected override void OnClosed(EventArgs e) { if (this.appWorkspace.ActiveDocumentWorkspace != null) { appWorkspace.ActiveDocumentWorkspace.SetTool(null); } base.OnClosed(e); //n send image to frmedit in cc13 CCI3.Forms.frmEdit s = new CCI3.Forms.frmEdit(); // s.mSetPicture(PictureBox, "true"); //s.VarEditImg //s.VarEditSig s.PicImage.Image = null; s.PicImage.Image = Image.FromFile(@"C:\Temp\Temp1.jpg"); s.PicImage.Refresh(); s.picSig.Image = null; s.picSig.Image = Image.FromFile(@"C:\Temp\Temp2.jpg"); s.picSig.Refresh(); //s.Con s.Showimg(); CCI3.Myimg g = new CCI3.Myimg(); g.Showimg2(); //CCI3.Forms.frmEdit ss = new CCI3.Forms.frmEdit(); //ss.setEditPictures(@"C:\Temp\Temp1.jpg", @"C:\Temp\Temp2.jpg"); }
-
here is the code on project 2 form2 closed event : CC13 is my frist project and i want to send image or update image in frmedit now tell me plz whats the problem image still not update: protected override void OnClosed(EventArgs e) { if (this.appWorkspace.ActiveDocumentWorkspace != null) { appWorkspace.ActiveDocumentWorkspace.SetTool(null); } base.OnClosed(e); //n send image to frmedit in cc13 CCI3.Forms.frmEdit s = new CCI3.Forms.frmEdit(); // s.mSetPicture(PictureBox, "true"); //s.VarEditImg //s.VarEditSig s.PicImage.Image = null; s.PicImage.Image = Image.FromFile(@"C:\Temp\Temp1.jpg"); s.PicImage.Refresh(); s.picSig.Image = null; s.picSig.Image = Image.FromFile(@"C:\Temp\Temp2.jpg"); s.picSig.Refresh(); //s.Con s.Showimg(); CCI3.Myimg g = new CCI3.Myimg(); g.Showimg2(); //CCI3.Forms.frmEdit ss = new CCI3.Forms.frmEdit(); //ss.setEditPictures(@"C:\Temp\Temp1.jpg", @"C:\Temp\Temp2.jpg"); }
CCI3.Forms.frmEdit s = new CCI3.Forms.frmEdit(); above line in your code makes a new instance. i'm saying it again u need to get a already opened instance reference. new keyword always make a new instance.
-
CCI3.Forms.frmEdit s = new CCI3.Forms.frmEdit(); above line in your code makes a new instance. i'm saying it again u need to get a already opened instance reference. new keyword always make a new instance.
-
hi ! i have two project in one solution , form1 from project 1 is running and i m calling from this to prject2 form 2 like that project2.form2 f = new project2.form2(); f.show(); on the buton of form1 call this and form is opening succesfully but when i closed the form2 then its back to form 1 , becouse form 1 is already opend then my question is that which event is fire when i got back to form1 , i checked Activated event is not working may b cumming from other project , may what is differnce b/w show and showdailogue() , when i call like f.showdailogue() ; then its just open and closed automatically . Further Detail : i have a image on form1 i move this image to form2 and edit that image and then save and when i return back to form1 then its should automatically update but its not updated , when i found the event then on that event in form1 i just reload the image to given path .
hello nomi do not use f.show(); project2.form2 f = new project2.form2(); f.show(); use f.showDialog(); by using this ur form2 will be shown as dialog box so that u would no switch to form one until u finish ur work n form2 . after u close form2 u will be back to ur position f.showDialog() and just after that refresh ur image. and please do not do this think in form activated event becoz there will be loading problem. if this answere is helpfull then donot forget to mark :-)
wasim khan
-
hi ! i have two project in one solution , form1 from project 1 is running and i m calling from this to prject2 form 2 like that project2.form2 f = new project2.form2(); f.show(); on the buton of form1 call this and form is opening succesfully but when i closed the form2 then its back to form 1 , becouse form 1 is already opend then my question is that which event is fire when i got back to form1 , i checked Activated event is not working may b cumming from other project , may what is differnce b/w show and showdailogue() , when i call like f.showdailogue() ; then its just open and closed automatically . Further Detail : i have a image on form1 i move this image to form2 and edit that image and then save and when i return back to form1 then its should automatically update but its not updated , when i found the event then on that event in form1 i just reload the image to given path .
Well I guess a simple solution to the problem would be to declare a public event (say OnEditFormClosing) and when you create an instance of the Form2 (the Image Edit Form), register that event (Handler of the event) in Form1 (Original Form). Now when you close Form2 (Edit Form), handle its 'Close Event' and from there Invoke the event (OnEditFormClosing), this will notify your Form1 that Form2 closed, as a result you can refresh the image in picture box may be by reloading or whatsoever procedure you adapt. Regards
Muhammad Talha