【问题标题】:C# If i click button2 (in form2) , label1 show in form 1 [closed]C#如果我点击button2(在form2中),label1显示在form 1中[关闭]
【发布时间】:2023-03-29 00:03:01
【问题描述】:

我的程序需要代码:我单击按钮 1,然后显示 form2,在 form2 中单击按钮 2,然后在 form1 中显示 label1 "WORK"。谁能帮我写这段代码??

【问题讨论】:

  • 恐怕没有人会为您编写代码。请显示您尝试过的代码,并指出您遇到困难并需要帮助的地方。有了这个,有人会尽力帮助你。
  • 很遗憾,您的问题也很难理解。
  • 这个问题不好:你应该阅读一些书籍来了解自己。

标签: c# winforms


【解决方案1】:

将此代码添加到 Form1 的按钮单击中,

private void button1_Click(object sender, EventArgs e)
{
    Form2 from2 = new Form2();
    Control[] button = from2.Controls.Find("button1", true);
    button[0].Click += new EventHandler(ShowLabel);

    from2.ShowDialog();
}

也添加这个Form1(在属性下设置WORK标签的可见属性为false

private void ShowLabel(object sender, EventArgs e)
{
    label1.Visible = true; //Setting WORK label's visible property to true
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多