首页 > 解决方案 > 在委托操作中标签不显示

问题描述

在按钮单击时,调度程序运行显示一个表单,其中mylab文本不显示,但是当在按钮方法mylab文本中放置相同的代码时,文本正在显示。

    private void button2_Click(object sender, EventArgs e)
    {

        int hour = DateTime.Now.Hour;
        int min = DateTime.Now.Minute;
        int i = 0;
        MyScheduler.IntervalInSeconds(hour, min + 1, 20,
        () =>
        {
            Form form = new Form();
            form.Text = "Modeless Window";
            

            form.TopMost = true;
            form.AutoSize = true;
            form.AutoSizeMode = AutoSizeMode.GrowAndShrink;

            Label mylab = new Label();
            mylab.Text = "Pls fill list";
            mylab.Location = new Point(10, 10);
            mylab.AutoSize = true;
            // Set the font of the content present in the Label Control
            mylab.Font = new Font("Calibri", 18);
            // Set the foreground color of the Label control
            mylab.ForeColor = Color.Red;

            form.Controls.Add(mylab);
            form.ControlBox = false;

            form.Show();


        });

    }

标签: c#winformsdelegates

解决方案


推荐阅读