最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

C# winform 解决win7环境下鼠标滚轮无法操作panel滚动条的问题

业界 admin 7浏览 0评论

帮助类代码如下:

class PanelScrollHelper
    {
        /// <summary>
        /// 初始化Panel
        /// </summary>
        /// <param name="panel"></param>
        public static void InitializePanelScroll(Panel panel)
        {
            panel.Click += (obj, arg) => { panel.Select(); };
            InitializePanelScroll(panel, panel);
            return;
        }

        /// <summary>
        /// 递归初始化Panel内部各容器和控件
        /// </summary>
        /// <param name="container"></param>
        /// <param name="panelRoot"></param>
        private static void InitializePanelScroll(Control container, Control panelRoot)
        {
            foreach (Control control in container.Controls)
            {
                if (control is Panel || control is GroupBox || control is SplitContainer ||
                    control is TabControl || control is User

帮助类代码如下:

class PanelScrollHelper
    {
        /// <summary>
        /// 初始化Panel
        /// </summary>
        /// <param name="panel"></param>
        public static void InitializePanelScroll(Panel panel)
        {
            panel.Click += (obj, arg) => { panel.Select(); };
            InitializePanelScroll(panel, panel);
            return;
        }

        /// <summary>
        /// 递归初始化Panel内部各容器和控件
        /// </summary>
        /// <param name="container"></param>
        /// <param name="panelRoot"></param>
        private static void InitializePanelScroll(Control container, Control panelRoot)
        {
            foreach (Control control in container.Controls)
            {
                if (control is Panel || control is GroupBox || control is SplitContainer ||
                    control is TabControl || control is User
发布评论

评论列表 (0)

  1. 暂无评论