C#: How do you send OK or Cancel return messages of dialogs when not using buttons?

后端 未结 3 1993
天命终不由人
天命终不由人 2020-12-15 02:46

C#: How do you send OK or Cancel return messages of dialogs when not using buttons?

How would you return the OK message in the condition of a textbox that will proce

3条回答
  •  失恋的感觉
    2020-12-15 03:10

    Set the form's DialogResult:

    this.DialogResult = DialogResult.OK;
    this.Close();
    

    This would cause any opener that opened this form with ShowDialog() to get the given DialogResult as the result.

提交回复
热议问题