c# - 鼠标移动时更新表单文本
问题描述
我有一个简单的表单,我想在用户移动鼠标时显示不断更新的光标位置。我遇到的问题是移动鼠标时文本没有更新。
public void mouse_position(object sender, MouseEventArgs e)
{
TextBox textBox1 = new TextBox();
Label label1 = new Label();
// Initialize the controls and their bounds.
label1.Location = new Point(1400, 500);
label1.Size = new Size(10, 10);
label1.BringToFront();
label1.BackColor = Color.Aqua;
// Add the Label control to the form's control collection.
Controls.Add(label1);
label1.Text = Cursor.Position.Y.ToString();
}
就像我说的,它给了我最初的鼠标位置,但从不更新
解决方案
推荐阅读
- php - PHP codeigniter 无法加载环境变量
- amazon-web-services - 我需要一种策略来处理 CDK 中的可选 SSM 参数存储参数
- node.js - 从 typescript 构建的 JS 文件如果独立运行会停止工作,但如果从 dist 文件夹运行则不会
- sed - Sed 表达式仅转换以某些示例短语开头的某些行
- java - 从 DB 中提取的 ArrayList 被 Java 覆盖
- react-native - How to suppress gradlew.bat changes in React Native
- javascript - node.js 函数陷入无限循环
- vue.js - 如何在 vue.js 中为 href 使用组件?
- django - 安装 Django 包 django-tenants 时出错
- java - 在 Java 中的循环内初始化 HashMap