Please see my comments to the question: some clarification is needed.
If you want to make a spacing between texts of different controls, this is trivial: just insert some spacer
Panel
between them, having the same value of
System.Windows.Controls.Dock
property, either
System.Windows.Forms.Top
or
System.Windows.Forms.Bottom
:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.dock.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.dockstyle.aspx[
^].
In principle, you can use this technique in a more complex case, see below.
So, what to do if you want to increase spacing in the rendered string shown with end line characters or auto word wrapping? This is pretty difficult, because neither
System.Drawing.Canvas
nor
System.Drawing.Font
has an appropriate property (but native GDI+ has, according to its documentation). One approach is this: you can parse the string into separate lines and render each line separately in some custom control in your
OnPaint
method. Such parsing is easy if the rendered line breaks are based only on end-of-line characters, but pretty difficult it the automatic word wrapping is used. In this case, you would need to measure each line's width:
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.measurestring.aspx[
^],
http://msdn.microsoft.com/en-us/library/7sy6awsb.aspx[
^].
The big problem here is that the width returned by these methods is not very accurate because it does not take
hinting (
http://en.wikipedia.org/wiki/Hinting[
^]) in account.
Now, for the alternative, you can use read-only
System.Windows.Forms.RichTextBox
where you can set a paragraphs line spacing:
http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.aspx[
^].
This would be much simpler; and the fact it's selectable is only for good: you can allow your customers to copy the text to clipboard, for example, to send an issue report. Experience shows that nearly all customers are physically unable to write what they could see on screen in an issue report.
—SA