如何倒在一个文本框在C#代码滚动 [英] How to scroll down in a textbox by code in C#

查看:131
本文介绍了如何倒在一个文本框在C#代码滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的WinForms,我在一段时间更新一次的文本框(显示消息)。
然而,当文本到达框的末尾它产生的滚动条,我不知道该怎么向下滚动至底部。我看到的唯一的事情就是ScrollToCaret,但插入符号是在文本的开头。什么是滚动的命令?

I am using winforms, and I update a text box once in a while (showing messages). however, when the text reaches the end of the box it produces scrollbars and I don't know how to scroll down to the bottom. The only thing I see is ScrollToCaret, but Caret is at the beginning of the text. What is the command to scroll?

推荐答案

您可以通过使用一个名为ScrollToCaret功能做到这一点。您需要先插入符位置设置为文本框的结尾,那么你可以滚动到它。以下是如何做到这一点:

You can do this by making use of a function called ScrollToCaret. You need to first set the caret position to the end of the text box, then you can scroll to it. Here's how to do it:

        //move the caret to the end of the text
        textBox.SelectionStart = textBox.TextLength;
        //scroll to the caret
        textBox.ScrollToCaret();

这篇关于如何倒在一个文本框在C#代码滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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