2017-11-06 4 views
0

C# Windows Forms 응용 프로그램에 System.Windows.Forms.TabPage이 포함 된 양식이 여러 개 있습니다 (System.Windows.Forms.ListView). TabPage에는 세로 스크롤 막대가 있습니다.C# ListView를 부모 컨테이너로 스크롤하는 방법

이 TabPage를 통해 스크롤하는 동안 마우스가 ListView 중 하나를 가리키면 스크롤이 중지됩니다.

이 문제를 해결하고 마우스가 ListView 중 하나를 가리키면 계속 스크롤 할 수있는 가장 좋은 방법은 무엇입니까?

내가 다음 코드를 사용하여 새 컨트롤 생성 :

답변

0

약간의 검색 후,이 내 솔루션이었다 마우스 휠이 제어에 사용되는

using System; 
using System.Windows.Forms; 

namespace MyApplication.Controls 
{ 
    public class ScrollableListView : ListView 
    { 
     [System.Runtime.InteropServices.DllImport("User32.dll")] 
     public static extern IntPtr PostMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); 

     protected override void WndProc(ref Message m) 
     { 
      const int WM_MOUSEWHEEL = 0x020A; 
      switch (m.Msg) 
      { 
       case WM_MOUSEWHEEL: 
        if (m.HWnd == Handle) 
        { 
         if (Parent is TabPage) 
          PostMessage((Parent as TabPage).Handle, m.Msg, m.WParam, m.LParam); 
        } 
        break; 
       default: 
        base.WndProc(ref m); 
        break; 
      } 
     } 
    } 
} 

을, 이벤트가 전송됩니다 상위 컨트롤에 부모 컨트롤이 System.Windows.Forms.TabPage 인 경우

관련 문제