Grasshopper

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?

Views: 510

Replies to This Discussion

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);

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service