垂直滚动Scintilla的文本框时文本已改变事件

垂直滚动Scintilla的文本框时文本已改变事件

本文介绍了垂直滚动Scintilla的文本框时文本已改变事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是一个完整的VS2010项目来重现问题: http://temp-share.com/show / dPf3aqi7W

Here is a complete VS2010 project to reproduce the problem: http://temp-share.com/show/dPf3aqi7W

设置Scintilla.Net文本框用绳子和滚动到最后一行不起作用。

Setting a Scintilla.Net textbox with a string and scrolling to last line doesn't work.

本问答集一个如何使自动滚屏在Scintilla的?有答案,但它不会工作的在同时设置文本

This Q & A How make autoscroll in Scintilla? has the answer but it wont work at the same time as setting the text.

裸露的骨头摄制:

private void button1_Click(object sender, EventArgs e)
{
    string s = RandomString(400);
    scintilla1.Text = s + " " + s + " " + s + " " + s + " " + s;
    scintilla1.Scrolling.ScrollBy(0, 10000);    //<-doesn't work (but does work eg in a Button2_click)
}

private static Random random = new Random((int)DateTime.Now.Ticks);
private string RandomString(int size)
{
    StringBuilder builder = new StringBuilder();
    char ch;
    for (int i = 0; i < size; i++)
    {
        ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
        builder.Append(ch);
    }
    return builder.ToString();
}

有谁知道如何设置文本后垂直向下滚动到端线?

Does anyone know how to scroll vertically down to end line after setting the text?

推荐答案

那么你可以尝试添加文本​​后,将刷新();

Well you can try to put Refresh() after adding the text;

scintilla1.Text = S ++ S ++ S ++ S ++ S;
  scintilla1.Refresh();

对于这种情况我发现,你将需要刷新()两次取决于你把文本框的字符串的长度。

for this case i found out that you will need to Refresh() twice depend on the length of the string you put on the textbox.

这篇关于垂直滚动Scintilla的文本框时文本已改变事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 19:35