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. C# Event Handling Questions

C# Event Handling Questions

Scheduled Pinned Locked Moved C#
csharphelptutorial
5 Posts 3 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.
  • J Offline
    J Offline
    joshp1217
    wrote on last edited by
    #1

    I am writing an application that basically has an sidebar and form_view_panel. This sidebar has X amount of buttons on it which correspond to loading specific forms in the form_view_panel. What I need to do is raise an event to the forms in the form_view_panel to let it know when a form change is about to occur(i.e. a toolbar button was clicked), if it(the form in the form_view_panel) wants to allow this to occur at that specific time then it responds back allowing the changing process to occur ORif it doesnt want to change at that point in time that it responds back not allowing the change to occur. So any suggestions on how to implement this using C# event handling methods. Any help will be greatly appreciated. Thank You

    J L 2 Replies Last reply
    0
    • J joshp1217

      I am writing an application that basically has an sidebar and form_view_panel. This sidebar has X amount of buttons on it which correspond to loading specific forms in the form_view_panel. What I need to do is raise an event to the forms in the form_view_panel to let it know when a form change is about to occur(i.e. a toolbar button was clicked), if it(the form in the form_view_panel) wants to allow this to occur at that specific time then it responds back allowing the changing process to occur ORif it doesnt want to change at that point in time that it responds back not allowing the change to occur. So any suggestions on how to implement this using C# event handling methods. Any help will be greatly appreciated. Thank You

      J Offline
      J Offline
      Jun Du
      wrote on last edited by
      #2

      If I understand correctly, you wanted to send a button-click event from one form to another. First, a button-click event has to be first handled by its container form. It cannot be sent to or handled by another form. This is how event model should work. That said, you still can notify any other forms that something interesting has happened. The simpliest (may not be beast) approach is making a callback into any interested forms from within the event handler and let them to further process the event if necessary. Hope this helps. Best, Jun

      J 1 Reply Last reply
      0
      • J Jun Du

        If I understand correctly, you wanted to send a button-click event from one form to another. First, a button-click event has to be first handled by its container form. It cannot be sent to or handled by another form. This is how event model should work. That said, you still can notify any other forms that something interesting has happened. The simpliest (may not be beast) approach is making a callback into any interested forms from within the event handler and let them to further process the event if necessary. Hope this helps. Best, Jun

        J Offline
        J Offline
        joshp1217
        wrote on last edited by
        #3

        The last thing you said is very interest...this callback seems to me to be at least a path for me to go down. Do you know have or know of any code examples?

        J 1 Reply Last reply
        0
        • J joshp1217

          I am writing an application that basically has an sidebar and form_view_panel. This sidebar has X amount of buttons on it which correspond to loading specific forms in the form_view_panel. What I need to do is raise an event to the forms in the form_view_panel to let it know when a form change is about to occur(i.e. a toolbar button was clicked), if it(the form in the form_view_panel) wants to allow this to occur at that specific time then it responds back allowing the changing process to occur ORif it doesnt want to change at that point in time that it responds back not allowing the change to occur. So any suggestions on how to implement this using C# event handling methods. Any help will be greatly appreciated. Thank You

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          See the MVC pattern on Wikipedia.com. The Controller can be used to provide the messaging across different views so that the views remain isolated.

          1 Reply Last reply
          0
          • J joshp1217

            The last thing you said is very interest...this callback seems to me to be at least a path for me to go down. Do you know have or know of any code examples?

            J Offline
            J Offline
            Jun Du
            wrote on last edited by
            #5

            Here is some pseudo code:

            private void ButtonHandler(object sender, System.EventArgs e)
            {
            	// code to cook someParameters is omitted here	
            
            	if(sender == this.buttonAdd)	
            	{
            		anotherForm.AddCallback( someParameters );
            	}
            	else if(sender == this.buttonModify)
            	{
            		anotherForm.ModifyCallback( someParameters );
            	}
            	else if(sender == this.buttonDelete)
            	{
            		anotherForm.DeleteCallback( someParameters );
            	}
            }
            

            Best, Jun

            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