Reinitialize Winform Form or Reload Form

Welcome Forums General PowerShell Q&A Reinitialize Winform Form or Reload Form

Viewing 0 reply threads
  • Author
    • #213057
      Topics: 1
      Replies: 0
      Points: 14
      Rank: Member

      So with this new found downtime I am adding a GUI to one of my modules to make it more user friendly.  I have created a form and it is opened using the ShowDialog() method.  Inside this form I have a panel I use to open other forms within the main form using the Show() method.  When I am done with one of these forms I want to close the form.  However if I want to reopen the form I get “Cannot access a disposed object”.  My work around for that is instead of closing the form I just hide it.  For most of the forms this works fine, however I have one form which is like a WMI query builder.  It’s highly dynamic and needs to be cleared before each use.  I have done a lot of web searches and I keep getting just clear the fields.  I could do that, but that seems like a lot of wasted code.  There has to be a way to reload the form in PS.  In C# I would just reinitialize the form, but I am not sure how to do that with PS.

      I have tried Update(), Refresh() and adding the logic for the form to a function and just called the function, but I still get the “Cannot access a disposed object” when I try to reopen it using the function.

      Is there a way to simply reload the form or reinitialize the form in PS?

Viewing 0 reply threads
  • You must be logged in to reply to this topic.