当前位置:首页 > 开发 > C# > 正文内容

C# 控件判断鼠标位置

C#1年前 (2024-12-30)
        /// <summary>
        /// 鼠标抬起事件
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            Point mouseLocation = this.PointToClient(Cursor.Position);
            if (this.ClientRectangle.Contains(mouseLocation))
            {
                //鼠标在控件区域上
            }
        }


转载请注明出处。

本文链接:http://pythonopen.com/?id=1644

相关文章

C# 复制图片到剪贴板

Clipboard.SetImage(pictureBox1.Image);...

在 C# 中实现类似于 Windows 资源管理器的“名称”排序方式

要在 C# 中实现类似于 Windows 资源管理器的“名称”排序方式,你需要考虑以下几点:1. 不...

C# 跳出foreach循环

在 C# 中,如果你想在 foreach 循环内部提前跳出当前这一轮循环,继续执行下一轮循环,可以使...

C# double转为string并保留两位小数

在 C# 中,可以使用多种方式将 double 类型的数据转换为 string 类型并保留两位小数,...

C# Control防闪烁

SetStyle(ControlStyles.AllPaintingInWmPaint |...

C# Graphics图像抗锯齿

g.SmoothingMode = SmoothingMode.AntiAlia...