4 つのリッチ テキスト エディターを備えたテキスト ベースのアプリケーションがあります。保存ボタンを押すと、これらすべてのリッチ テキスト エディターのコンテンツを 1 つの RTF ファイルに保存する必要があります。
1150 次
1 に答える
1
これは、特にエレガントではありませんが、機能するソリューションです。
Dim temprtb As New RichTextBox
With temprtb
.Select(temprtb.TextLength, 0)
.SelectedRtf = RichTextBox1.Rtf
.Select(temprtb.TextLength, 0)
.SelectedRtf = RichTextBox2.Rtf
.Select(temprtb.TextLength, 0)
.SelectedRtf = RichTextBox3.Rtf
.Select(temprtb.TextLength, 0)
.SelectedRtf = RichTextBox4.Rtf
.SaveFile("C:\Users\Admin\Documents\test.rtf")
End With
新しいリッチテキスト ボックスを作成し、既存のリッチテキスト ボックスの内容を追加して、ファイルを保存します。
EDITよりエレガントな解決策は、すべてのリッチテキストボックスをパネルに配置してループすることです。
Dim temprtb As New RichTextBox
For Each c As Control In Panel1.Controls
If TypeOf (c) Is RichTextBox Then
temprtb.Select(temprtb.TextLength, 0)
temprtb.SelectedRtf = DirectCast(c, RichTextBox).Rtf
End If
Next
temprtb.SaveFile("C:\Users\Admin\Documents\test.rtf")
于 2012-10-29T13:42:55.377 に答える