algorithmic modeling for Rhino
I want to open a Form window when doubleclicking my component.
With the following code I managed to to that, but then if I close the form by clicking the topright red cross everything crashes.
// Code #1
Application.Run(new NN_Form_Main());
I tried running a new thread: the code executes but nothing pops up.
// Code #2
Thread window = new Thread(new ThreadStart(Run)); //2
private void Run()
{
Application.Run(new NN_Form_Main());
}
What am I doing wrong?
Tags:
You can not put UI controls on different threads. That will crash.
I also have no idea what Application.Run really does, but it sounds like the wrong approach.
To show a form, you typically do the following:
Form newForm = new MyDesignedForm(); // We assume you've made a form class, rather than making one from scratch through code.
newForm.Show();
You can also use ShowDialog() to put the form up as a modal one.
If you want your form to be on top of the Grasshopper window, you can assign a parent form:
newForm.Show(Grasshopper.Instances.DocumentEditor);
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by