zoukankan      html  css  js  c++  java
  • 支持同步滚动的RichTextbox控件 分类: .NET 20130423 13:00 416人阅读 评论(1) 收藏

    1. using System.Windows.Forms;  
    2.   
    3. public class SynchronizedScrollRichTextBox : System.Windows.Forms.RichTextBox  
    4. {  
    5.     public SynchronizedScrollRichTextBox Synchronized { getset; }  
    6.     public const int WM_VSCROLL = 0x115;  
    7.     public const int EM_LINESCROLL = 0xB6;  
    8.   
    9.     protected override void WndProc(ref System.Windows.Forms.Message msg)  
    10.     {  
    11.         if (msg.Msg == WM_VSCROLL || msg.Msg == EM_LINESCROLL)  
    12.         {  
    13.             if (Synchronized != null)  
    14.             {  
    15.                 Message message = msg;  
    16.                 message.HWnd = Synchronized.Handle;  
    17.                 Synchronized.PubWndProc(ref message);  
    18.             }  
    19.         }  
    20.         base.WndProc(ref msg);  
    21.     }  
    22.   
    23.     public void PubWndProc(ref System.Windows.Forms.Message msg)  
    24.     {  
    25.         base.WndProc(ref msg);  
    26.     }  
    27. }  


    思路参考了中文英文多篇资料,没有比较完整的,所以,算原创也不为过。

    我的博客向来简单明了,以上代码,复制到你项目中。编译一次,拖到窗体中即可,例如:

    拖2个实例,然后在设计界面,分别设置 Synchronized 属性为对方。运行,两个文本框就可以关联起来了。


  • 相关阅读:
    VS2013安装与部署工具中添加 vcredist_x64.exe
    ZeroMQ高水位标记(high-water mark,HWM)
    Ubuntu16.04 动态链接库(.so)查询路径设置
    ubuntu16.04开机启动字符界面
    python 全局搜索路径
    learning to rank
    数据集
    hadoop streaming 文档
    机器学习:一些感想
    矩阵分解 推荐
  • 原文地址:https://www.cnblogs.com/configman/p/4657566.html
Copyright © 2011-2022 走看看