Wednesday, December 5, 2012

Overriding ShowDialog() in C#

Overriding ShowDialog() is not possible in WinForms because there is no overridable method declared for it in Form Class. But there is a way there is will:


 public partial class FormA : Form
    {
        public FormA()
        {
            InitializeComponent();
        }

        public DialogResult ShowDialog(string mes)
        {
            this.textBox1.Text = mes;
            return base.ShowDialog();
        }
        public DialogResult ShowDialog()
        {
           // Your Code
            return base.ShowDialog();
        }
    }

No comments:

Post a Comment