1
I am involved in a small personal project, composed of some classes and many photons. I need to send a value that is obtained when I access a certain button, to 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 accessing a button, the value of that button (text) is inserted in the listbox.
Apparently the problem here is that you are creating a new instance of
ListBoxthat is not the one you included in your form.– iuristona