【发布时间】:2021-11-04 20:52:13
【问题描述】:
我正在尝试获取它,因此当您单击按钮(即开始)时,它会为您带来两个按钮,noob 和 medium。我不知道如何让第二个出现。 ID 用于 button1,所以我尝试将第二个重命名为 button1,但不起作用。如何再次传递 button1 以使其从一个按钮逻辑生成两个按钮?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace App2341
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
button1.Text = "Noob";
button1.Location = new Point(100, 100);
}
private void Button2_Click(object sender, EventArgs e)
{
button1.Text = "Medium";
button1.Location = new Point(100, 150);
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
【问题讨论】:
-
"Spawn" 不是计算机科学或编程术语。你到底是什么意思?
-
上下文中的措辞好吗?我希望按钮在单击时从一个按钮产生两个按钮,目前只有一个
-
目前您没有创建任何按钮,而是修改现有的
button1。您可以事先创建两个新按钮,然后根据需要使它们可见。或者您使用new Button()动态创建它们。 -
如何使它们不可见,然后在点击时可见?
标签: c#