Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Which Event is Fire !

Which Event is Fire !

Scheduled Pinned Locked Moved C#
questionannouncement
13 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nomi
    wrote on last edited by
    #1

    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 .

    N W T 3 Replies Last reply
    0
    • N nomi

      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 .

      N Offline
      N Offline
      Nouman Bhatti
      wrote on last edited by
      #2

      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.

      N 1 Reply Last reply
      0
      • N Nouman Bhatti

        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.

        N Offline
        N Offline
        nomi
        wrote on last edited by
        #3

        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 .

        G N 2 Replies Last reply
        0
        • N nomi

          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 .

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          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.

          N 1 Reply Last reply
          0
          • G Guffa

            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.

            N Offline
            N Offline
            nomi
            wrote on last edited by
            #5

            please tell me the code becouse i m new in c#

            1 Reply Last reply
            0
            • N nomi

              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 .

              N Offline
              N Offline
              Nouman Bhatti
              wrote on last edited by
              #6

              The reason it's not updating bcz u r making a new instance.. on formclosing event but u need the already open instance.

              N 1 Reply Last reply
              0
              • N Nouman Bhatti

                The reason it's not updating bcz u r making a new instance.. on formclosing event but u need the already open instance.

                N Offline
                N Offline
                nomi
                wrote on last edited by
                #7

                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

                N 1 Reply Last reply
                0
                • N nomi

                  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

                  N Offline
                  N Offline
                  Nouman Bhatti
                  wrote on last edited by
                  #8

                  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.

                  N 1 Reply Last reply
                  0
                  • N Nouman Bhatti

                    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.

                    N Offline
                    N Offline
                    nomi
                    wrote on last edited by
                    #9

                    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"); }

                    N 1 Reply Last reply
                    0
                    • N nomi

                      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"); }

                      N Offline
                      N Offline
                      Nouman Bhatti
                      wrote on last edited by
                      #10

                      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.

                      N 1 Reply Last reply
                      0
                      • N Nouman Bhatti

                        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.

                        N Offline
                        N Offline
                        nomi
                        wrote on last edited by
                        #11

                        meri jan ma bhi yeh hi keh rha hon there is no any more instance Except of this yaaaar y u r not getting my point i only make object or instance one time and its that i send u

                        1 Reply Last reply
                        0
                        • N nomi

                          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 .

                          W Offline
                          W Offline
                          wasimsharp
                          wrote on last edited by
                          #12

                          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

                          1 Reply Last reply
                          0
                          • N nomi

                            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 .

                            T Offline
                            T Offline
                            telha
                            wrote on last edited by
                            #13

                            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

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups