[英]How do you open a file and view it in a FastColoredTextBox component in c#
I'm developing an HTML editor where you can edit code inside the FastColoredTextBox.dll component. 我正在开发一个HTML编辑器,您可以在其中编辑FastColoredTextBox.dll组件中的代码。 I have an option for the SaveFile which i covered here .
我在这里介绍了SaveFile的选项。
So can anyone help with this? 那么有人可以帮忙吗? Please help.
请帮忙。
You just have to load file like to default winforms textbox. 您只需要像默认的winforms文本框一样加载文件。 fastColoredTextBox1 is just extended textbox.
fastColoredTextBox1只是扩展的文本框。 I tried it and it works like charm.
我尝试过,它就像魅力。
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == DialogResult.OK)
{
var loadedText = File.ReadAllText(ofd.FileName);
fastColoredTextBox1.Text = loadedText;
}
内置方法是OpenFile
,它可以按预期初始化控件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.