|
-
May 22nd, 2012, 09:22 PM
#1
Thread Starter
Junior Member
Tab Control Scrolling
I have a tab control with two tab pages. One page has the auto scroll enabled since there is to much content in the page.
The middle mouse wheel doesn't scroll the scroll bar; I have to actually click and hold the scroll bar and drag it down to scroll. Is there a property to allow this?
Thanks,
-
May 22nd, 2012, 11:01 PM
#2
Re: Tab Control Scrolling
 Originally Posted by TechMe.NET
I have a tab control with two tab pages. One page has the auto scroll enabled since there is to much content in the page.
The middle mouse wheel doesn't scroll the scroll bar; I have to actually click and hold the scroll bar and drag it down to scroll. Is there a property to allow this?
Thanks,
I see the TabControl MouseWheel event fires when a tabpage has focus (and controls inside the tabpage do not have focus) when you use the mousewheel, but like you say the scroll bar for the tab control doesn't get effected.
I'm not sure if there is some setting to make it work that way, I didn't see anything offhand so came up with this real quick,...
Code:
Public Class Form1
<System.Runtime.InteropServices.DllImport("user32.dll")> _
Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
End Function
Private Const WM_VSCROLL As Int32 = &H115
Private Const SB_LINEUP As Int32 = 0
Private Const SB_LINEDOWN As Int32 = 1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
TabControl1.TabPages(0).AutoScroll = True
TabControl1.TabPages(1).AutoScroll = True
End Sub
Private Sub TabControl1_MouseWheel(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles TabControl1.MouseWheel
If e.Delta > 0 Then
' scroll selected tabpage upwards
SendMessage(TabControl1.TabPages(TabControl1.SelectedIndex).Handle, WM_VSCROLL, SB_LINEUP, 0)
Else
'scroll selected tabpage downwards
SendMessage(TabControl1.TabPages(TabControl1.SelectedIndex).Handle, WM_VSCROLL, SB_LINEDOWN, 0)
End If
End Sub
End Class
-
May 23rd, 2012, 08:00 AM
#3
Thread Starter
Junior Member
Re: Tab Control Scrolling
I think I found a better solution. It looks like the middle mouse isn't activated until you click a control/item in the tabpage. I was able to set focus on the tabpage with a enter event using this code Me.ActiveControl = Me.TabPage1
 Originally Posted by Edgemeal
I see the TabControl MouseWheel event fires when a tabpage has focus (and controls inside the tabpage do not have focus) when you use the mousewheel, but like you say the scroll bar for the tab control doesn't get effected.
I'm not sure if there is some setting to make it work that way, I didn't see anything offhand so came up with this real quick,...
Code:
Public Class Form1
<System.Runtime.InteropServices.DllImport("user32.dll")> _
Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
End Function
Private Const WM_VSCROLL As Int32 = &H115
Private Const SB_LINEUP As Int32 = 0
Private Const SB_LINEDOWN As Int32 = 1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
TabControl1.TabPages(0).AutoScroll = True
TabControl1.TabPages(1).AutoScroll = True
End Sub
Private Sub TabControl1_MouseWheel(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles TabControl1.MouseWheel
If e.Delta > 0 Then
' scroll selected tabpage upwards
SendMessage(TabControl1.TabPages(TabControl1.SelectedIndex).Handle, WM_VSCROLL, SB_LINEUP, 0)
Else
'scroll selected tabpage downwards
SendMessage(TabControl1.TabPages(TabControl1.SelectedIndex).Handle, WM_VSCROLL, SB_LINEDOWN, 0)
End If
End Sub
End Class
Last edited by TechMe.NET; May 23rd, 2012 at 02:25 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|