Create Buttons in dynamic form (C #) [closed]

0

I am working in a sales application with c # and I want to make it possible to filter by category in the window where the products are chosen to be sold, but that each category is a button and that the user can select the category he wants there, the thing is that the user can create as many categories as he wants and my query is if you can create buttons automatically based on the number of categories.

PS: I try to do something like This

    
asked by Andres Cabrera 11.01.2017 в 00:39
source

1 answer

1

Look at this ...

      public Form1()
    {
        InitializeComponent();
        Button[,] boton = new Button[10, 10];
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                boton[i, j] = new Button();
                boton[i, j].Width = 40;
                boton[i, j].Height = 20;
                boton[i, j].Text = String.Format("{0},{1}", i, j);
                boton[i, j].Top = i * 20;
                boton[i, j].Left = j * 40;
                this.Controls.Add(boton[i, j]);
            }
        }
    }

I hope you serve

    
answered by 11.01.2017 / 01:06
source