I am involved in a small personal project, composed of some classes and many forms. I need to send a value that is obtained when I access the given button, for the listbox that is in one of these forms. For this I chose to build a method called beverageclick with the following code
public void beverageclick(object sender, EventArgs e)
{
Button b = (Button)sender;//button sender
string value = (string)b.Tag;// value = b.tag (tag of sended button tag = value (value of AddBeverageDrinkstoTabbedPanel) method)
beverages.Add(value);
//get value
//MessageBox.Show(value);
ListBox lstbox = new ListBox();
lstbox.Items.Add(value);
}
How can I change the above code so that when I access a button, the value of that button (text) is inserted into the listbox.