Click here to Skip to main content
15,889,595 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a custom control that used a lot of Label controls inside, and i started experiencing performance issues when drawing/redrawing the screen So i decided to remove them as they look overwhelming and just draw the texts I needed

I started using Graphics.DrawString method, which was SUPER fast and the performance when resizing/redrawing the screen was perfect, but then I noticed the text render wasn't exactly the same as the one Labels uses, and didn't look that good.

I then found out about TextRenderer.DrawText method and I switched to it, but the problem came back again, when you resize the form/control the performance is awful.

Is this a normal behavior? I researched a bit and came to read that TextRenderer.DrawText is preferable and better as it uses GDI+ as opposed as GDI, but this clear is not my case?

We are talking about a 100% standard WinForm vb.net app with VisualStyles enabled.

What I have tried:

VB
TextRenderer.DrawText(e.Graphics, "Hello World", Me.Font, New Rectangle(1, 1, 200, 20), Me.ForeColor, TextFormatFlags.Left)

e.Graphics.DrawString("Hello World", Me.Font, _Brush, New Rectangle(1, 1,200, 20), _StringFormat)
Posted
Updated 4-May-18 8:38am
v3

1 solution

 
Share this answer
 
Comments
creizlein 4-May-18 20:39pm    
Thanks, that seems to be good information !
Wendelius 4-May-18 23:46pm    
You're welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900