Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
514 views
in Technique[技术] by (71.8m points)

.net - How to prevent a Windows Forms TextBox from flickering on resize?

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.

Here are a couple of related questions:

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 TableLayoutPanels the flicker on resize is even worse.

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...