Search code examples
c#listbuttontabpage

How add many buttons to TabbedPanel?


I am developing a solution in C # and I need to add a few buttons to TabbedPanel. Happens that debugger adds only one and even a single button.

 public void AddDrinkstoTabbedpanel(TabPage tp)
        {

              List<string> drinks = new List<string>();//New list empty
              food foo = new food();//Call food to get drinks
              string []product = foo.name;//string product [] = food.name (drink)
              foreach (string value in product)//(string value in product)//for any "value" in product 
              {

                  Button bt = new Button();
                  bt.Size = new Size(100, 100);
                  drinks.Add(value);

                  tp.Controls.Add(bt);

                  //listofButtons.Add(bt);

              }


        }

I previously define an array with some items and now i need to add a button for each item founded, how can I modify this code given above to get what I want.


Solution

  • Change the Location for all buttons. They are being created but at the same position and look like one.