【问题标题】:Windows form button displays textbox and enter name to create new button [closed]Windows 窗体按钮显示文本框并输入名称以创建新按钮 [关闭]
【发布时间】:2013-06-06 21:51:55
【问题描述】:

我如何做一个按钮show textbox,在textbox 内输入名称并按回车键,然后它会创建一个按钮,其名称放在面板中的textbox 中?

【问题讨论】:

  • 欢迎先阅读FAQ
  • 你有什么尝试吗?
  • 顺便说一句:无需在问题标题中添加标签。

标签: c# windows forms button panel


【解决方案1】:

不幸的是,C# 中没有 InputMessageBox。 但您可以使用 Interaction.InputBox 引用“Microsoft.VisualBasic”和 dann。

using Microsoft.VisualBasic;


  // Click-Event
  private void btn_GetName_Click(object sender, EventArgs e)
  {
        string btnTxt = Interaction.InputBox("Title", "Message", "defaultValue", 10, 10);

        Button button1 = new Button();
        button1.Location = new Point(20, 10);
        button1.Text = btnTxt;
        this.Controls.Add(button1);
  }

这是一个非常简单的任务,请下次使用 Google 或发布一些代码来调试您的错误。

顺便说一句:StackOverflow 中还有很多其他解决方案。

【讨论】:

    猜你喜欢
    • 2013-06-05
    • 1970-01-01
    • 2010-09-14
    • 2013-06-05
    • 1970-01-01
    • 2016-06-27
    • 2014-10-06
    • 1970-01-01
    相关资源
    最近更新 更多