C#图形绘图问题。 [英] C# Graphics Drawing Problem.

查看:67
本文介绍了C#图形绘图问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我制作了一个工具,用于比较2个富文本框中的文本,然后标记红色不同的字符。一个选项需要我重叠这两个文本数据以显示确切的差异。我使用了一个包含在面板中的图片框,并使用Graphics类以相应的颜色绘制字符。一切都很好,但由于某种原因,我需要点击两次按钮才能在图片框上看到一些东西。没有任何内容作为事件处理程序分配给图片框或面板。下面是代码,在最后一行我用sleep方法实际看看会发生什么。令人惊讶的是,当系统处于睡眠状态这2秒钟时,我实际上可以正确地看到数据,但是在这2秒之后,图片框就清晰了。我再次点击按钮,这次它在2秒睡眠后仍然停留。请告诉我哪里出错了?任何帮助都非常感激。


另外,我使用的是最新的Visual Studio 2010测试版,终极版,也许这也是一个原因,但我想在做之前确保旧版本的新项目。由于MS不支持向后兼容性。


再次感谢您再次提前...


Hi,

I made a tool that compares the texts from 2 richtextboxes and then marks the characters that are different in red. An option needs me to overlap these 2 text data to show the exact difference. I used a picturebox which is contained in a panel and draw the characters in respective colors using Graphics class. Everything is working fine, but for some reason I need to click the button twice to be able to see something on picturebox. There is nothing assigned as event handlers to either picturebox or panel. Below is the code for that, in the last line I used the sleep method to actually see what happens. Surprisingly when the system is in sleep for these 2 seconds, I can actually see the data correctly, but after these 2 seconds the picturebox is clear. I click on the button again and this time it stays even after the 2 seconds sleep. Please tell me where I am going wrong ? Any help is really appreciated.

Also, I am using the latest Visual Studio 2010 Beta, Ultimate version, maybe this is also a reason, but just want to make sure before I make a new project in older version. As no backward compatibility is supported by MS.

Thank You Once Again in Advance...


展开 | 选择 | Wrap | 行号

推荐答案

提示:当您在撰写问题时,工具栏上有一个按钮将[code]标签包装在您的复制/粘贴代码周围。它有助于一堆。它的按钮上有一个''#''。 有关标签的更多信息。他们很酷。 Check''em出来。
TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a ''#'' on it. More on tags. They''re cool. Check''em out.


我可能会建议摆脱第114行。完成后没有理由睡2个完整秒。
I might suggest getting rid of line 114. There is no reason to sleep for 2 full seconds when done.

@tlhintoq


感谢tlhintoq快速回复......


睡觉我用于诊断目的,数据仅在这2秒内准确显示,之后图片框变为空白。当我第一次单击此按钮2时,在第二次单击时,即使在此睡眠之后数据仍保持不变。我摆脱了这种睡眠,然后再次将数据显示在图片框中,但仅在2次点击后,或上述代码的2次迭代。
@tlhintoq
Thanks tlhintoq for a quick response......

That sleep I used it for diagnosis purpose, the data is accurately displayed only during these 2 seconds, after that the picturebox goes blank. This is the case when I click this button2 first time, in the second click the data stays even after this sleep. I got rid of this sleep and then again the data is displayed in picturebox but only after 2 clicks, or 2 iterations of the above code.


这篇关于C#图形绘图问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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