I'm currently writing a custom control for use with a WinForms application - basically, it's a hex editor control, which displays offsets, rows of bytes, a text column, and some other information.
I'm doing all the drawing inside OnPaint, but I've started to notice that rendering becomes a little laggy when the control is large (and thus a lot of bytes are being drawn). In extreme cases it can take around 20 to 30 milliseconds to draw the entire control. This isn't terrible, but it makes dragging selections feel very slightly sluggish, and I'm sure it's much worse on lower-end machines.
The control is entirely text based - aside from a couple Graphics.DrawPath/FillPath calls, the bulk of the GDI+ calls are to Graphics.DrawString (one for each byte displayed, to allow for custom column spacing). These DrawString calls end up taking up the vast majority of the rendering time.
Is there any faster way to do text drawing in GDI+? It seems that it would be a good move to try to reduce the number of DrawString calls, but how can I do that while still maintaining control over the spacing of characters?
Perhaps there's another, simpler way of rendering text for this purpose that I'm just unaware of? Any advice would be appreciated.