Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

WindowsForm doesn't open again when closed in an add-in

Anonymous

WindowsForm doesn't open again when closed in an add-in

Anonymous
Not applicable

Hello community!

I've made a add-in for inventor with many windows-forms. But if one form has been closed when the addin in inventor is running, it doesn't open again. How can i avoid this problem? I read something about to use the .hide() command on the red-x-close-button in windows forms, but i couldn't get it work. Does anyone know the problem or a solution?

I'm looking forward to every idea, so i can finally finish my project.

Best regards
Colli

0 Likes
Reply
Accepted solutions (1)
421 Views
2 Replies
Replies (2)

manuel.lanthaler
Enthusiast
Enthusiast

Hello,

 

there are two possibilites:

 

  • If you want to open the same form again, then you can hide and show the form as per your needs:

 

//while closing the window in the close event
this.Hide(); // hide the form instead of closing
e.Cancel = true; // this cancels the close event.

 

//While opening check like this
if(!form.Visible)
{
  form.Show();
}

 

  • If you dont want to open again the same, then you have to get sure that the form and all its child windows are closed / disposed correctly and you can create a new instance of the form using the new () operator.

 

hope it helps

 

Manuel

coolOrange
www.coolOrange.com
––––––––––––––––––
Please mark this response as "Accept as Solution" if it answers your question.
If you have found any post to be helpful, even if it's not a direct solution, then please provide that author kudos.


0 Likes

Anonymous
Not applicable
Accepted solution

Thanks for your answer 🙂

I already found a solution but forgot to post it.

In my case i open a windowsform by clicking a selfmade button in the ribbon panel of inventor.
I had to place the constructor for the windowsform into the button_click handling sub, not above into the class.
If the constructor is placed in the class, only one windowsform object will be constructed by button click and if it gets closed it will not get constructed by every next button click.
When the constuctor is placed in the button_click sub, the windowsform objekt will be new constructed every time the button gets clicked.

0 Likes