0

I am trying to make a sort of notification within my form. The panel will consist of a rich textbox followed by two buttons underneath it.

Design of panel

I would need a way of programatically displaying new panels with different data in each one and having it displayed so that it can be scrolled. Initially, i have tried to create a table layout panel and then a panel. I could not figure out how to create a new instance of the panel i created in designer to place it into the table layout.

If there is another simple way of achieving my goal of having a group of controls being added beneath each other programatically i would appreciate it.

anonymous_
  • 51
  • 1
  • 7
  • Look at my answer here : https://stackoverflow.com/questions/37165402/c-sharp-adding-button-with-value-at-runtime – jdweng Feb 20 '20 at 12:02
  • Is the question how to add something to `TableLayoutPanel` in code behind? – Sinatr Feb 20 '20 at 12:16

1 Answers1

0

You can use this code to generate dynamic controls, but i am just sharing with you sample code.

        int n = 10;
           Panel[] p=new Panel[n];
           int j = 10;
           for (int i=0;i<n;i++)
           {
                j += 10;
                p[i] = new Panel();
                p[i].BorderStyle = BorderStyle.Fixed3D;
                p[i].Height = 100;
                p[i].Location = new Point(100,10+j);
                this.Controls.Add(p[i]);
           }
Sunny
  • 1
  • 1