winform-RichTextBox--隐藏滚动条

1,窗体加载的时候:

            this.rtx_abnormalData.ScrollBars = RichTextBoxScrollBars.None;
            this.rtx_abnormalData.MouseWheel += Rtx_abnormalData_MouseWheel;
            //this.rtx_abnormalData.ContentsResized += Rtx_abnormalData_ContentsResized;

  

2,事件代码:

        //private void Rtx_abnormalData_ContentsResized(object sender, ContentsResizedEventArgs e)
        //{
        //    rtx_abnormalData.Height = e.NewRectangle.Height + 10;
        //}

        private void Rtx_abnormalData_MouseWheel(object sender, MouseEventArgs e)
        {
            if (e.Delta > 0)
            {
                if (rtx_abnormalData.SelectionStart > 10)
                {
                    rtx_abnormalData.SelectionStart -= 10;
                    rtx_abnormalData.ScrollToCaret();
                }
            }
            else
            {
                rtx_abnormalData.SelectionStart += 10;
                rtx_abnormalData.ScrollToCaret();
            }
        }

  

原文地址:https://www.cnblogs.com/baozi789654/p/14622042.html