Lion1505 发表于 2017-3-16 15:53

【总结】RichTextBox 添加防闪烁

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

class MyRichTextBox : RichTextBox
{
    public void BeginUpdate()
    {
      SendMessage(this.Handle, WM_SETREDRAW, (IntPtr)0, IntPtr.Zero);
    }

    public void EndUpdate()
    {
      SendMessage(this.Handle, WM_SETREDRAW, (IntPtr)1, IntPtr.Zero);
                this.Invalidate();
        }

   
    private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
    private const int WM_SETREDRAW = 0x0b;
}

/*
        MyRichTextBox rch = new MyRichTextBox();
        rch.BeginUpdate();
        ... 大数据量添加 ...
        rch.EndUpdate();
*/

开始学习ing 发表于 2017-3-20 22:17

页: [1]
查看完整版本: 【总结】RichTextBox 添加防闪烁