开发者

How can I tell if a form was displayed with ShowDialog?

开发者 https://www.devze.com 2023-02-03 05:09 出处:网络
I\'m developing a custom control that doesn\'t inherit from Button. I wan开发者_如何学Ct to implement a functionality similar to the DialogResult from the standard button, setting the FormParent.Dialo

I'm developing a custom control that doesn't inherit from Button. I wan开发者_如何学Ct to implement a functionality similar to the DialogResult from the standard button, setting the FormParent.DialogResult to the specified value on PerformClick and then closing it.

However, I need to know if the form has been shown with ShowDialog instead of Show (i.e., if it's a modal window).

Is there an easy way to achieve this?


Use the Form.Modal property, eg:

if(this.Modal)
    Debug.WriteLine("Hooray, I am a modal form");
0

精彩评论

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