如何创建文本编辑 [英] How to create a text edit
问题描述
您好,
我只是想知道使用常规文本框而不是那些富文本框创建可视化基本文本编辑器是否完全可行。
我目前正在使用可视化基本代码和Windows窗体进行作业。我正在尝试创建一个文本编辑器,我设计的表单没有问题,我的问题是:我能够使用常规文本框而不是富文本框来打开,保存和创建文件吗?
**目前使用工具条打开,保存和创建文件等**
< b>我尝试了什么:
我尝试过使用富文本框。下面是富文本框的代码,但它只允许我使用rtf文件,我希望它允许任何文件
Hello,
I was just wondering if it was at all posible to create a visual basic text editor using regular textboxes instead of those rich text boxes.
I am currently working on an assignment using visual basic code and windows forms. I am trying to make a text editor, I've designed the form no problem, my question is: am i able to use regular textboxes instead of rich textboxes to open, save and create files??
** Currently using toolstrips to open, save, and create files, etc **
What I have tried:
I've tried using the rich textboxes. Below is the code to the rich textboxes but it only allows me to use rtf files and I want it to allow ANY files
Try
Dim dialog As OpenFileDialog = New OpenFileDialog
dialog.Title = "Open"
dialog.Filter = "Rich Text Files(*.rtf)|*.rtf"
If dialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
InputTextBox.LoadFile(dialog.FileName)
End If
Catch ex As Exception
End Try
推荐答案
它只允许我使用rtf文件,我想要它允许任何文件
it only allows me to use rtf files and I want it to allow ANY files
然后不添加过滤器 - 这条线强制用户只选择RTF文件:
Then don't add a filter - it's this line that forces the user to only select RTF files:
dialog.Filter = "Rich Text Files(*.rtf)|*.rtf"
删除它,用户可以选择他想要的任何类型的文件。
然后就是了让你能够阅读它:这就是乐趣开始的地方,因为并非所有文件类型都具有人类可读性。
Remove that, and the user can select any type of file he wants.
It's then up to you to be able to read it: and that's where the fun begins as not all file types are even slightly "human readable".
这篇关于如何创建文本编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!