如何prevent Windows窗体文本框从闪烁在调整大小? [英] How to prevent a Windows Forms TextBox from flickering on resize?
问题描述
有很多的文章在Windows窗体解决闪烁。大多数建议设置 DoubleBuffered = TRUE
或设置一堆 ControlStyle
标志。然而,这些都不利于降低一个TextBox闪烁。
There are plenty of articles addressing flicker in Windows Forms. The majority recommend setting DoubleBuffered = true
or setting a bunch of ControlStyle
flags. However, none of these help reduce a TextBox flickering.
下面是几个相关问题:
- 如何在窗体上双缓冲.NET控件?
- <一个href="http://stackoverflow.com/questions/64272/how-to-eliminate-flicker-in-windows-forms-custom-control-when-scrolling">How滚动时消除闪烁Windows.Forms的中自定义的控制?
- How to double buffer .NET controls on a form?
- How to eliminate flicker in Windows.Forms custom control when scrolling?
要重现该问题,创建一个新的WinForms项目,添加一个文本框
,启用多行,禁用自动换行,加上一堆文字,设置锚
来左+右+上衣+底。现在运行和调整。文字闪烁。对于里面的一对夫妇的嵌套的TableLayoutPanel
文本框S上调整大小的闪烁更是雪上加霜。
To reproduce the issue, create a new WinForms project, add a TextBox
, enable multi-line, disable word-wrap, add a bunch of text, set Anchor
to Left+Right+Top+Bottom. Now run and resize. The text flickers. For text boxes inside a couple of nested TableLayoutPanel
s the flicker on resize is even worse.
在应用时最好不解决闪烁的上述问题提出了解决方案;如果我得到的实验,并设置保护 ControlStyle
在文本框
我可以通过启用 UserPaint
),但不能消除闪烁。
Applying the solutions proposed in the above questions at best do not fix the flicker; if I get experimental and set the protected ControlStyle
on TextBox
I can break it completely (by enabling UserPaint
) but not eliminate the flicker.
那么,有没有什么办法都解决了文本框的文字闪烁?
So, is there any way at all to fix the flickering of the text in a TextBox?
推荐答案
我平时用的的RichTextBox ,而不是一个多行TextBox。 由DetectUrls-和ShortcutsEnabled-属性设置为false RTB的行为非常相似,一个文本框和...它的无闪烁的。
I usually use a RichTextBox instead of a multiline TextBox. By setting the DetectUrls- and ShortcutsEnabled-properties to false the RTB behaves very similar to a TextBox and ... it's flicker-free.
这篇关于如何prevent Windows窗体文本框从闪烁在调整大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!