部队的richtextbox滚动条刷新 [英] Force Richtextbox scrollbars to refresh

查看:212
本文介绍了部队的richtextbox滚动条刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题是有关的WinForms的RichTextbox。

This question is about WinForms RichTextbox.

我有一个滚动条属性设置为垂直一个RichTextBox。

I have a RichTextbox with ScrollBars property set to Vertical.

我改变它的从code RTF内容,有时垂直滚动条显示为禁用 - 当它应该被启用。这不应该发生 - 滚动条应该是启用,或不显示在所有。 (我在VB6的应用程序也有类似的问题,当滚动条,有时并没有出现在所有的时候应该)。

I change it's RTF contents from the code and sometimes the vertical scrollbar appears disabled - when it should be enabled. This should never happen - the scrollbar should be either enabled, or not shown at all. (I had a similar issue in my VB6 app, when the scrollbar sometimes didn't appear at all when it should).

有没有办法如何强制的RichTextbox滚动刷新,通过的PInvoke或来解决这个问题的任何其他方式?

Is there any way how to force the RichTextbox scrollbars to refresh, via PInvoke or any other way to fix this issue?

感谢。

推荐答案

我终于理解了它!如果有人需要这样的:

I've finally figured it out! In case anyone needs this:

1)创建一个新的控制继承自RichTextBox控件

1) Create a new control that inherits from the richtextbox control

2)添加这个code:

2) Add this code:

Public Sub FixScrollbars()
    RecreateHandle()
End Sub

3)调用它时,你改变.RTF属性。

3) Call it whenever you change the .RTF property.

这篇关于部队的richtextbox滚动条刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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