Is it possible to overload the ShowDialog method for forms and return a different result?

前端 未结 4 2550
渐次进展
渐次进展 2021-02-20 06:04

EDIT: This method actually works great and I asked it then found the solution later. I added the correct call in the overloaded ShowDialog() method (it\'s not exacly an over

4条回答
  •  孤街浪徒
    2021-02-20 06:14

    Try this, it seems to work for me:

     public partial class Form2 : Form
        {
            public Form2()
            {
                InitializeComponent();
            }
    
            public DialogResult ShowDialog(string mes)
            {
                this.textBox1.Text = mes;
                return base.ShowDialog();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                this.Close();
            }
        }
    

提交回复
热议问题