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. Initiating a process from child

Initiating a process from child

Scheduled Pinned Locked Moved C#
csharpquestion
5 Posts 2 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.
  • L Offline
    L Offline
    Lodeclaw
    wrote on last edited by
    #1

    Hi everyone, I just recently started programming in C# (my first language, also) and I'm still pretty green. I was wondering how, or if it's possible, to initiate a process in a parent form when a boolean variable in it's child form is set to "true". I see events such as "text changed" but I need something in the parent that can catch a variable change on the child as soon as it occurs and take action right away. Any suggestions? Thanks! :)

    M L 2 Replies Last reply
    0
    • L Lodeclaw

      Hi everyone, I just recently started programming in C# (my first language, also) and I'm still pretty green. I was wondering how, or if it's possible, to initiate a process in a parent form when a boolean variable in it's child form is set to "true". I see events such as "text changed" but I need something in the parent that can catch a variable change on the child as soon as it occurs and take action right away. Any suggestions? Thanks! :)

      M Offline
      M Offline
      musefan
      wrote on last edited by
      #2

      you could try creating your own events in the child class and handling them in the parent class. look here for good example: http://www.ondotnet.com/pub/a/dotnet/2002/04/15/events.html[^]

      L 1 Reply Last reply
      0
      • M musefan

        you could try creating your own events in the child class and handling them in the parent class. look here for good example: http://www.ondotnet.com/pub/a/dotnet/2002/04/15/events.html[^]

        L Offline
        L Offline
        Lodeclaw
        wrote on last edited by
        #3

        Not really what I need, but thank you.

        M 1 Reply Last reply
        0
        • L Lodeclaw

          Not really what I need, but thank you.

          M Offline
          M Offline
          musefan
          wrote on last edited by
          #4

          I dont think you can take another approach. If you want to do something, when another form changes you need to listen for that change. I dont know what your exact requirements are but perhaps you could use static functions in another class. Or just call the function by accessing the child forms parent form. something like (though i have not tested):

          FormOfTypeParent parentForm = (FormOfTypeParent)this.ParentForm;
          parentForm.MyFunction();

          FormOfTypeParent = the form type that is your parent form i.e. MainForm, Form1 etc. calling this when a variable changes, make the variable a property i.e.

          private bool changingThing = false;

          public bool ChangingThing{
          get{return changingThing;}
          set{changingThing = value;ProcessChange();}
          }

          private void ProcessChange()
          {
          if(changingThing)
          {
          FormOfTypeParent parentForm = (FormOfTypeParent)this.ParentForm;
          parentForm.MyFunction();
          }
          }

          1 Reply Last reply
          0
          • L Lodeclaw

            Hi everyone, I just recently started programming in C# (my first language, also) and I'm still pretty green. I was wondering how, or if it's possible, to initiate a process in a parent form when a boolean variable in it's child form is set to "true". I see events such as "text changed" but I need something in the parent that can catch a variable change on the child as soon as it occurs and take action right away. Any suggestions? Thanks! :)

            L Offline
            L Offline
            Lodeclaw
            wrote on last edited by
            #5

            I am attempting to find another way to get around this problem, so I have another question regarding this: Is it possible to call an event in a child form from the parent form? I've attempted this in the past without success, but I feel that it should be possible given that events that don't involve "physical" (such as a button click event) components on the form can be called by the parent. Can anyone verify this and/or explain why/how it is or is not possible? Thanks so much!

            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