更改文本框滚动条的位置? [英] Change scrollbar position in TextBox?

查看:623
本文介绍了更改文本框滚动条的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想换一个文本框的滚动条,做什么我需要做的,除了这个位置:

If I want to change the position of a TextBox's scrollbar, what do I need to do besides this:

SetScrollPos(IntPtr hWnd, int nBar, int nPos, bool bRedraw);

此功能只改变滚动条的位置,但它不会更新实际文本框(这样滚动条羊皮卷,但文本没有)。有什么建议么?我使用的是Windows窗体和.NET 4,与Visual Studio 2008。

This function only changes the scrollbar position, but it doesn't update the actual TextBox (so the scrollbar "scrolls", but the text doesn't). Any suggestions? I'm using Windows Forms and .NET 4, with Visual Studio 2008.

推荐答案

我通常做的:

textBox1.Select(textBox1.Text.Length, 0);
textBox1.ScrollToCaret();

如果选择0字只是将光标移动到需要的位置(在本例中code:在文本的末尾)。

Where selecting 0 characters just moves the cursor to the desired location (in the example code: at the end of the text).

这篇关于更改文本框滚动条的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆