How to add dynamic control into a dynamic control also?

183 views Asked by At

The following codes creates dynamic codes which the numbers of control varies from database.

        FlowLayoutPanel flowlayout = new FlowLayoutPanel();
        flowlayout.Dock = DockStyle.Fill;
        flowlayout.AutoScroll = true;

        while (reader.Read())
        {  
            Button button = new Button();
            button.Size = new Size(500, 200);
            button.Name = reader["fname"].ToString();
            button.Text = reader["userID"].ToString();
            button.BackColor = Color.Black;
            button.ForeColor = Color.White;
            button.Dock = DockStyle.Top;
            flowlayout.Controls.Add(button);

        }
        panel1.Controls.Add(flowlayout);

Then I want to add this control into a dynamic Panel control which created during runtime.

0

There are 0 answers