如何通过单击按钮创建按钮

时间:2018-05-24 01:04:30

标签: c# visual-studio

所以这是按钮的代码(btnUser.cs)

public class btnUser : Button
    {
        public int x = 0;
        public int y = 100;
        public int z = 65;
        public btnUser()
        {
            BackColor = Color.Transparent;
            FlatAppearance.BorderSize = 0;
            FlatStyle = FlatStyle.Flat;
            Font = new Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Bold);
            ForeColor = Color.DarkOrange;
            Location = new Point(x, y);
            Padding = new Padding(0, 0, 10, 0);
            Size = new Size(268, 59);
            TextAlign = ContentAlignment.MiddleRight;
            UseVisualStyleBackColor = false;
        }

    }

这就是我尝试的方式

private void button1_Click(object sender, EventArgs e)
        {
            users++;
            BtnUser.btnUser btu = new BtnUser.btnUser();
            btu.Name = "btnUser" + users;
            btu.Text = btu.Name;
            components.Add(BtnUser.btnUser btu.Name);
        }

我想知道正确的解决方案,如果我点击另一个按钮就自动弹出一个按钮。 感谢您的回答:)

0 个答案:

没有答案