无法在运行时以编程方式影响 Scintilla 控制

发布于 08-24 20:53 字数 518 浏览 10 评论 0原文

我正在尝试在我正在处理的应用程序中使用 ScintillaNET 控件。我将控件拖放到窗体中并运行窗体。该控件出现在窗体上。这很好。此外,如果我在控件的属性编辑器中设置任何属性(例如,ConfigurationManager.Language),我就可以输入该语言并看到语法突出显示。

当我尝试以编程方式更改属性时,我遇到了问题。例如,我尝试将文件中的文本加载到表单中(我在表单的“加载”中执行此操作)。文本不显示。我似乎也无法显示行号或执行任何其他数量的任务(包括以编程方式更改语言)。

知道我可能做错了什么吗?即使像下面的代码这样简单的东西似乎也不起作用:

private void scintilla1_Load(object sender, EventArgs e)
{
    scintilla1.ConfigurationManager.Language = "xml";
}

I'm attempting to use the ScintillaNET control in an application I am working on. I drag and drop the control into my form and run form. The control appears on the form. This is good. In addition, if I set any of the properties in the control's properties editor (ConfigurationManager.Language, for example), I am able to type in that language and see syntax highlighting occur.

Where I run into problems is when I attempt to change properties programmatically. For example, I attempt to load text from a file into the form (I'm doing this in the form's Load). The text doesn't display. I also can't seem to show the line numbers or do any other number of tasks (including programmatically change the Language).

Any idea what I may be doing wrong? Even something as simple as the code below doesn't seem to work:

private void scintilla1_Load(object sender, EventArgs e)
{
    scintilla1.ConfigurationManager.Language = "xml";
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

顾冷2024-08-31 20:53:01

只需添加 scintilla1.ConfigurationManager.Configure();

private void scintilla1_Load(object sender, EventArgs e)
{
    scintilla1.ConfigurationManager.Language = "xml";
    scintilla1.ConfigurationManager.Configure();
}

Simply add scintilla1.ConfigurationManager.Configure();

private void scintilla1_Load(object sender, EventArgs e)
{
    scintilla1.ConfigurationManager.Language = "xml";
    scintilla1.ConfigurationManager.Configure();
}
秋意浓2024-08-31 20:53:01

花了一些时间研究不同的事件后,看来我无法影响 Scintilla 控件,直到它已经可见。因此,在将控件设置为可见之前,“加载”事件不允许我对控件进行任何编程更改。

这有点奇怪,对我来说加载事件似乎毫无意义,但我只是想让每个人都知道发生了什么,以防其他人遇到同样的问题。

After spending some time playing around with the different events, it appears that I cannot affect the Scintilla control until after it is already visible. Hence, the "Load" event does not let me make any programmatic changes to the control until I've set it visible.

It's a little strange, and seems sort of pointless to me to have the Load event at all, but I just wanted to let everybody know what is happening in case someone else ran into the same problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文