I create a Component with Visual studio, which include a class (use NewGrasshopperTemplate to creat) and a Form. the Form was started by clicking menu in the class. When the data in the Form is calculated, how to output the calculated data to the output of the Component?
That means it’s modal, i.e. the rest of the UI is locked until the window is closed, and the next line of code to execute after the window is closed is the line after form.ShowDialog(). If you had used Show() instead then the code continues on running right away and the window does not lock the UI. The modal way is easier to deal with because you don’t have to worry about events or callbacks.
After form.ShowDialog(); you must harvest the new values in the form class and apply them to your component. Probably you’d store them as a class level variable, then read that variable from within SolveInstance().
You must also trigger a new solution once the form closes, which can be done via ExpireSolution(true).
I’d recommend against creating forms inside SolveInstance, you should create the form only just before you need it and dispose of it when you’re done. That means I imagine the code might look a bit like this: