0
我试图打开一个.RTF到一个格式文本框RTF不开放到RichTextBox中正确
每次我打开它把这个到格式文本框的文件:
http://pastebin.com/jwYwds9y [显示原料RTF]
这是我的代码打开:
Public Sub openFile()
Dim ofd As New OpenFileDialog
ofd.Filter = fileFilter
ofd.FileName = ""
Select Case ofd.ShowDialog()
Case DialogResult.OK
loadFile(ofd.FileName)
End Select
End Sub
Public Sub loadFile(ByVal file As String)
Try
fileName = file
setText(IO.File.ReadAllText(file))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Public Sub setText(ByVal value As String)
Dim t As RichTextBox = tabH.SelectedTab.Controls.OfType(Of RichTextBox)().First()
t.Text = value
End Sub
我有一个选项卡控件并没有主要的文本框,当应用程序运行时,它使用代码添加第一个标签。代码:
Public Sub newFile()
Dim t As New TabPage
Dim p As New RichTextBox
t.Text = "Untitled"
p.Parent = t
p.Dock = DockStyle.Fill
tabH.TabPages.Add(t)
t.Visible = True
AddHandler p.KeyDown, Sub(sn As Object, e As KeyEventArgs) makeChanged()
End Sub
你试过't.Rtf = value'吗? –
@AndrewMorton你应该写这个答案,因为这很可能是解决方案。 –
@VisualVincent有时需要我花时间思考我可以如何有效地填充一个非常简短的答案,以增加一些价值。 –