Home > OS >  Too many arguments to show a form, but works in another project - Almost same code
Too many arguments to show a form, but works in another project - Almost same code

Time:05-02

I'm trying to get started with my first add-in for Autodesk Inventor, and of course, I'm starting from an existing sample to make this task easier for a newbie like me.

I have a decent command of VB.NET, but I cannot understand what's going on here.

In this link: Working Sample

Does not work here

Any help is welcome - Thanks in advance!

CodePudding user response:

In your project This_Sample_Does_Not the class dockable_form is a Control (the class inherits from System.Windows.Forms.UserControl).

In the reference project This_Sample_Works the class form_dockable is a Form (the class inherits from System.Windows.Forms.Form).

The two are very different types, though a Form can behave like a Control, the opposite is not true. A control will need a containing form.

Thus, the Control does not have a Parent that can be assigned when the method Show is called, it already has a parent.

From MSDN - Control.Show Method

Showing the control is equivalent to setting the Visible property to true. After the Show method is called, the Visible property returns a value of true until the Hide method is called.

Questions for your final preferred solution:

  • Do you really want to create a Control that is placed on another form? or
  • Do you want a Form that can be shown or popped up as required?
  • Related