How make autoscroll in Scintilla?

烈酒焚心 提交于 2019-12-02 13:48:10

问题


I have a simple VB.NET application using Scintilla. I don`t know how can I make the control auto scroll when text is added to it.

Can anyone help?

Thanks


回答1:


Done.

Scintilla can auto-scroll by calling:

Scintilla1.Scrolling.ScrollBy(0, Scintilla1.Lines.Count)

so it scrolls to the last text line.




回答2:


The accepted solution didn't work for me when trying to make a ScintillaNET editor control scroll to the bottom line after updating the Text property. Perhaps it's because I am embedding it in a WPF WindowsFormsHost. In any event, here is the code I used to make the ScintillaNET editor control auto-scroll in my context. (Note, the code is in C#):

// Declaration for the WinAPI SendMessage() method.
[DllImport("user32.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, uint wMsg, UIntPtr wParam, IntPtr lParam);

/// WM_VSCROLL -> 0x0115
public const int WM_VSCROLL = 277;

/// SB_BOTTOM -> 7
public const int SB_BOTTOM = 7;

// scintillaCtl should be a reference to the Scintilla control you want to scroll vertically.
SendMessage(scintillaCtl.Handle, WM_VSCROLL, new UIntPtr(SB_BOTTOM), IntPtr.Zero);


来源:https://stackoverflow.com/questions/2898722/how-make-autoscroll-in-scintilla

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!