Invalidate() 命令不会重新绘制控件

发布于 2024-08-21 10:34:18 字数 159 浏览 6 评论 0原文

我正在尝试开发一个需要绘制一些矩形的自定义控件。现在,需要移动 1 个矩形,因此我使用重写的 mousemove 方法来获取新位置并更改该矩形的位置部分,然后使用 Invalidate() 命令。但问题是,整个控件被绘制而不是那个矩形。它正在消失。如果有人能指出我做错的地方,那将是一个很大的帮助。谢谢。

I am trying to develop a custom control which needs to have some rectangles to be drawn. Now, 1 rectangle needs to be moved so I used overrided mousemove method to get the new location and change the location part of that rectangle and then used Invalidate() command. But problem is, that whole control is painted instead of that rectangle. It is disaapearing. If someone can point out where I am doing wrong, that would be a great help. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

剧终人散尽 2024-08-28 10:34:18

您可以使用 Invallidate() 重载来部分无效。将一个矩形作为参数传递给 Invalidate(),或者您可以传递 4 个数字来执行此操作。

Invalidate(new Rectangle(left, top, width, height));

当然,您必须使矩形的旧位置和新位置无效。

You can use partial invalidate using Invallidate() overloads. pass a rectangle as a parameter to Invalidate() or you can pass 4 number to do it.

Invalidate(new Rectangle(left, top, width, height));

of course you must invalidate rectangle's old place and new place.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文