现在的位置: 首页 > 综合 > 正文

C# Winform ListView控件没有滚动条,自己写了一个扩展控件

2013年05月26日 ⁄ 综合 ⁄ 共 1008字 ⁄ 字号 评论关闭

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace PosCommonCls
{
    public class ListViewEx : ListView
    {
        //public delegate void ScrollEventHandler(object sender, EventArgs e);
        public event EventHandler HScroll;
        public event EventHandler VScroll;
        public ListViewEx()
        {
        }
        const int WM_HSCROLL = 0x0114;
        const int WM_VSCROLL = 0x0115;
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == WM_HSCROLL)
            {
                OnHScroll(this, new EventArgs());
            }
            else if (m.Msg == WM_VSCROLL)
            {
                OnVScroll(this, new EventArgs());
            }
            base.WndProc(ref m);
        }
        virtual protected void OnHScroll(object sender, EventArgs e)
        {
            if (HScroll != null)
                HScroll(this, e);
        }
        virtual protected void OnVScroll(object sender, EventArgs e)
        {
            if (VScroll != null)
                VScroll(this, e);
        }
    }

}

这里只能触发事件,可惜没法返回具体拖动的值,需要自己处理了

抱歉!评论已关闭.