V
V
Valentine2018-11-05 09:03:48
C++ / C#
Valentine, 2018-11-05 09:03:48

How to perform one function for all buttons on a form?

There are a lot of buttons on the form, each of which has a unique name corresponding to one of the text files in the program folder. It is required that by clicking on a button in the MessageBox the desired text file is opened. For example, there was a click on a button with name(Name)== Hello . The Hello.txt file should open , if the button name is World , then World.txt .

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
leremin, 2018-11-05
@val_gr

One handler for all buttons, and in it something like string filename = (sender as Button).Name + ".txt"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question