문제

C# richtextbox의 경우, 수직 스크롤 막대 상단의 위쪽 화살표를 클릭하는 것과 같은 작업을 프로그래밍 방식으로 수행하고 싶습니다. 이것에 대한 코드는 무엇입니까? 감사!

도움이 되었습니까?

해결책

내가하는 일은 다음과 같습니다.

using System.Runtime.InteropServices;

[DllImport("user32.dll")]
static extern int SendMessage(IntPtr hWnd, uint wMsg, 
                               UIntPtr wParam, IntPtr lParam);

그런 다음 전화 :

SendMessage(myRichTextBox.Handle, (uint)0x00B6, (UIntPtr)0, (IntPtr)(-1));

그래도 잘 작동하는 것 같습니다.하지만 조금 조정해야 할 수도 있습니다.

도움이되기를 바랍니다.

다른 팁

For future reference the EM_LINESCROLL message is what you send to any multi-line edit control to set the scroll position. You can scroll vertically or horizontally. See MSDN for details.

You can also use the Rich Edit Selection method, where you set the character index (which you can get with EM_LINEINDEX) then call RichEdit.ScrollToCaret ie:

RichEdit.SelectionStart = SendMessage(RichEdit.Handle, EM_LINEINDEX, ScrollTo, 0);
RichEdit.ScrollToCaret();

This will scroll that line to the top of the edit control.

window.scrollBy(0,20);

This will scroll the window. 20 is an approximate value I have used in the past that typically equals one line... but of course font size may impact how far one line really is.

If you can get the scroll control for the rich text box, you should be able to get its SmallChange property and use that to scroll the text.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top