F
F
foxlye2019-10-04 19:35:30
C++ / C#
foxlye, 2019-10-04 19:35:30

How to create form elements on button click?

How to create form elements on button click?
Let's say I have a button button1, I need to click on it to create a checkbox on the form. How to do it ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Stupenkov, 2019-10-04
@foxlye

In the button click handler:

private void button1_Click(object sender, EventArgs e)
    {
      CheckBox cb = new CheckBox();
      cb.Text = "check box";
      this.Controls.Add(cb);
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question