开发者

.NET Winform Custom Form - Needs to return DialogResult or somehow prevent asynchronous events

开发者 https://www.devze.com 2023-01-16 00:25 出处:网络
I have a form that calls a custom child form.The child form is basically a popup box that gets some user data.

I have a form that calls a custom child form. The child form is basically a popup box that gets some user data.

I want the Parent form to process information returned by the Child form.

The problem is, the Parent form is calling the Child, and isn't waiting for a reply.

Ideally, I'd like to make the Child form return a DialogResult. Functionally, this is clear what's happening (especially since the user has the option to Cancel the child control) and seems like a simple way to force the pare开发者_JS百科nt to wait. I haven't figured out how to do this though.

The secondary problem is, the Parent control proceeds beyond the childDialog.Show() event, and tries to process the Child control's info. Which hasn't been altered yet.

Setting up a condition using public values of the Child control, such as childDialog.UserClickedOK, don't do a thing to help, since the default values are still in effect.

What am I overlooking?

Thanks everyone! :)


You need to show the form modally, using ShowDialog instead of Show. Inside your child form, you set the DialogResult to whatever makes the most sense given the user interaction that happened before.

0

精彩评论

暂无评论...
验证码 换一张
取 消