Grasshopper

algorithmic modeling for Rhino

Hi,

I would like to ask how to get value from windows form?

I got the windows form working and it appears in additional menu on the component.

following the post windows forms

public void DisplayForm()
{
CuvatureAnalysis frm = new CuvatureAnalysis();
Grasshopper.GUI.GH_WindowsFormUtil.CenterFormOnCursor(frm,true);

if (frm.ShowDialog() == DialogResult.OK)
//Harvest values from form and assing them to local variables

this.ExpireSolution(true);
}

Views: 1497

Attachments:

Replies to This Discussion

I usually declare the form as a private member of the GH component. Then you can add functions on both sides (the component and the form), to access the values you want to modify. To call the parent (in this case the GH component) you have to pass a pointer to it somehow to the form. I would say the easiest is to create a parameterized constructor for the form, where the parameter is a reference to the parent. 

EDIT: Ok, so I took a closer look at your code, guess you're already on the track descibed above. When you add any control to the form, you can access it and it's values from the form... so if you have a TextBox1 on the form, you just type Me.TextBox1.Text (it's this.TextBox1.Text in C#). You can change the control's name in its properties. 

Thanks for a reply.

I just had to add variable to

public partial Class LearnMoreFormName : Form

and now I see it the component class:)

Hi Petras,

I Realise this post is two years old, so I hope I'll get a response...

Would you be so kind to post your code?

I'm also trying to build a windows form on a grasshopper component right now. 

The goal is to have a form in which the user will be able to select a value from an input list (done in grasshopper), or add a new value to this list. The selected value should then be input for the component.

The "Select Key" listbox is inherited from an input. The output (of the form) should be a list of strings.

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