c# - 在委托操作中标签不显示
问题描述
在按钮单击时,调度程序运行显示一个表单,其中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();
});
}
解决方案
推荐阅读
- sql-server - 识别和禁用链接到特定表的所有触发器
- c# - 循环遍历 MongoDB 集合并在 C# 中加入它们
- javascript - 如何优化此 Google Apps 脚本?它所做的只是读取和写入数据,但它需要永远
- azure - 新 AzureStorageContext:端点与环境
- javascript - 使用 JavaScript 从 HTML 表单执行 2 个操作
- javascript - 如何告诉网站正在使用电子?
- android - 删除未使用的资源
- javascript - PHP 会话数据未在 HTTPS 环境的同一域内从页面传输到页面
- python - 在 Python 中创建自定义枚举
- android - 在三星 S 系列或谷歌像素设备上找不到钛加速器相机