在窗口上拖动窗口时刷新或重新绘制Windows窗体 [英] Windows Form refresh or repainting when a window is draged over it

查看:140
本文介绍了在窗口上拖动窗口时刷新或重新绘制Windows窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用C#2010和.net 4.0编写的Windows窗体.一个非常烦人的问题是,当一个人拖动一个窗口或其上的任何东西时,查看数据就是刚刚被拉到窗口上的窗口的图像.该表格正在移动大量数据/文件,并且在很大的一段时间内没有更新表格.我已经添加了"Application.DoEvents()","this.Invalidate()","Update()"和"Refreshes()".我需要知道如何在拖动窗体时停止在窗体顶部的另一个窗口的显示.我还希望能够随时单击该表单,使它成为焦点并提升到最高级别.
有关如何执行此操作的任何信息都将有所帮助.

I have a windows Form written in C# 2010 with .net 4.0. A very annoying problem is when one drags a window or anything over it the viewing data is images of the window that was just pulled over it. This form is doing large amount of data/ file moving and there are large periods that the form is not being updated. I have added " Application.DoEvents()", and "this.Invalidate()" , and "Update()" and "Refreshes()" to no avail. I need to know how to stop the imaging of another window on top of my form when dragged accost it. I would also like to be able to click on the form at any time and cause it to become in focus and to raise to the top level.
Any information on how to do this would be helpful.

推荐答案

天哪,不要执行DoEvents!您只需要Invalidate,但这应该是System.Windows.Forms.Control渲染的一部分,即使您不移动任何东西,但是您正在修改图片(例如在动画中).如果您可能在渲染或数据表示本身方面有问题,但是您什么也没显示.换句话说,通常不需要执行任何特殊操作即可处理表单的拖动.

首先,您可以尝试制作一个完整但简短的代码示例,该示例将显示此问题并将其发布在您的问题中.如果您选择这样做,请使用改善问题". (我的意思是不要重复很多查询者所犯的一个非常常见的错误:不要将其发布为解决方案".)顺便说一下,通过制作此简短示例,您将有更多机会自己解决问题.

—SA
Gosh, don''t do DoEvents! You only need Invalidate, but this should be a part of your System.Windows.Forms.Control rendering even if you are not moving anything, but you picture is being modified (like in animation). If''s likely that you have some problem in rendering or data presentation itself, but you did not show anything. In other words, normally you would not need to do anything special to handle dragging of your form.

First, you could try to make a complete but short code sample which would manifest this problem and post it in your question. If you choose to do that, use "Improve question". (I mean don''t repeat a very common mistake many inquirers do: don''t post it as "solution".) By the way, by making this short sample you will get an extra chance to figure out the problem by yourself.

—SA


这篇关于在窗口上拖动窗口时刷新或重新绘制Windows窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆