单击按钮时,调度程序运行,该调度程序显示一种形式,其中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();
});
}