私はvb.netでWindowsアプリケーションを開発しています。その中で私はフォームの1つにRichTextBoxコントロールを持っています。今、私はリッチテキストボックスにいくつかのパディングが必要です。したがって、私のテキストは、Word文書のようなスペース(パディング)の後に始まります。
では、RichTextBoxコントロールにパディングを与える方法を誰かに教えてもらえますか?
前もって感謝します。
私はvb.netでWindowsアプリケーションを開発しています。その中で私はフォームの1つにRichTextBoxコントロールを持っています。今、私はリッチテキストボックスにいくつかのパディングが必要です。したがって、私のテキストは、Word文書のようなスペース(パディング)の後に始まります。
では、RichTextBoxコントロールにパディングを与える方法を誰かに教えてもらえますか?
前もって感謝します。
There is no built-in property to allow for padding. You could create your own control and handle the painting yourself (or find someone else who has - http://www.codeproject.com/Articles/21437/A-Padded-Rich-Text-Box-Subclass); but you might be able to easily achieve the look you want by docking the RichTextBox inside of a Panel.
Panel does have a Padding
property.
If you use the same BackColor it might give the desired affect. Scroll bars might look 'off' though; if you need it to scroll things will get more complicated - I think you'd be able to use a VScrollBar - with the same height as the Panel but managing the scrolling will get complicated. You'd want to stop the RichTextBox from showing it's scroll bar; but you'll need to manage the scrolling with the VScrollBar.
If there aren't any better solutions offered up; I'll give this a try tonight and see if I can get it working :)
私も同様の問題を抱えていましたが、これは私にとって、そして少なくとも左マージンに対してはうまくいきました。基本的に、すべてのテキストを選択してインデントを設定しました。
With RTB 'This changes the left margin for the whole thing
Dim OldSelStart As Integer = .SelectionStart
Dim OldSelLen As Integer = .SelectionLength
.SelectionStart = 0
.SelectionLength = Len(.Text)
.SelectionIndent = 10
.SelectionStart = OldSelStart
.SelectionLength = OldSelLen
End With