This topic contains 6 replies, has 2 voices, and was last updated by
September 6, 2019 at 9:38 pm #175129
I am looking for a way of blanket tracking events of a form object in windows forms. Something like Register-ObjectEvent -EventName *
Is it possible?
September 10, 2019 at 12:22 am #175600
Please provide more detail and/or example of what you are trying to accomplish. If you have any code written already please share where we can assist in identifying any errors. If you are looking for someone to write the code for you that is not the scope of this forum.
September 10, 2019 at 5:07 pm #175813
Good day, Jason.
I am creating a GUI interface based on windows.forms. Now, on the form, there are three objects: datagridview and two buttons. I'd like to log events firing as a user interacts with the form. But to do it comprehensively i have to Register-ObjectEvent for every conceivable EventName. That is why i was wondering is there a way to register an Action scriptblock which would fire for all events no matter what. I'd like to write something like
Register-ObjectEvent -InputObject $form -EventName *
But it isn't allowed.
September 10, 2019 at 5:42 pm #175837
What are you adding into the $Form variable? Again we need to see the code to understand what you are trying to accomplish, you are welcome to change what you need to for any proprietary information. However without the code its going to be limited, have you researched the Register-ObjectEvent yet? Below are some links for research.
Help Register-Object -Full
September 10, 2019 at 8:12 pm #175930
i have read both the help and the Scripting Blog article.
i am looking for a one liner which gets one subscriber subscribed to all (not just one) event types of a given object.
i've already typed a one liner which, i imagine, would be good to have, but it does not work that way.
September 18, 2019 at 3:50 pm #178089
Sorry for the delay on my end. Been extremely busy from my end. Can you give an example of what you are trying to accomplish? If you are building a GUI, why are you attempting to make it a one liner? Sorry if I'm asking questions that are obvious, brain has to kick back into gear.
September 19, 2019 at 7:06 pm #178461
Imagine a situation where you build a GUI and you want to log ALL events on a form, simply to know what events and in what order happen. In order to do this you have to know the names of all events of all objects in the form including the form itself. Then you have to hard code every event processing scriptblock.
What if you could, instead of writing Register-ObjectEvent -InputObject $form -EventName "Certain event", write Register-ObjectEvent -InputObject $form -EventName * (notice the asterisk). So that with one Register-ObjectEvent you subscribe to ALL events of an object and all the child objects.
You must be logged in to reply to this topic.