Calling modal window and getting something back

Hello all

Using WinForms. I'd like to call a modal window, do some stuff (define an object in there) and get something back.

Here's how i imagined it, but please tell me if it's the proper way, and if now, what is the proper way of doing this.

  1. i could initialize the object in caller method and give that objects reference to the form constructor, so that form would work with that object (i have C++ background so this sounds like the way to do it)
  2. in my form, define a property holding that object, so when form ends, it sets the property to the finished object, who i can access from the calling method. From the top of my head, I'm not 100% sure how would that work: i shouldn't really close the form, correct?

Please tell me what's the proper way for a form to return value.

thanks

by 1and7aint8but17 via /r/csharp

Leave a Reply