T
T
TechNOIR2018-04-05 09:53:43
C++ / C#
TechNOIR, 2018-04-05 09:53:43

C#. How to pass button text to ButtonClick?

Good afternoon.
Can you please tell me how to pass the button text to ButtonClick?
There is a roombut button, with a text property.
It is necessary to pass this text to the button click event for further processing.. But I don’t understand how to do it correctly.. Thank you in advance!

roombut.Text = "Текст";
roombut.Click += new System.EventHandler(this.ButtonClick);

    void ButtonClick(object sender, EventArgs e)
    {
      this.panel1.Visible = true;
      
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2018-04-05
@TechNOIR

var text = ((Button)sender).Text;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question