滚动条 [英] Scrollbars
本文介绍了滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个树视图,一个检查列表视图控制一个在另一个旁边。我想要让它们工作,所以当我向下滚动或向上滚动其中一个时,
其他也一样。
任何帮助将不胜感激
-
Dino Buljubasic
软件开发人员
http://rivusglobal.com
解决方案
您将不得不使用Windows API使另一个控件滚动
。捕获您希望成为
主控制器的onVScroll事件并让它向从控制器发送消息。
您需要使用User32.DLL并使用常量发送消息
垂直滚动到另一个控件的句柄。
HTH
" Dino M. Buljubasic" <二************* @ rivusglobal.com>在消息中写道
新闻:GK ********************** @ news2.telusplanet.ne t ...我有一个树视图,一个选中的列表视图控制着另一个。我想让它们工作,这样当我向下滚动或向上滚动其中一个时,
其他也一样。
任何帮助都将受到赞赏
-
Dino Buljubasic
软件开发人员
http:// rivusglobal。 com
树视图或选中列表视图没有onVScroll事件。
"单手男[OHM] < te *************************** @ BTOpenworld.com>
在留言新闻中写道:%2 **************** @ tk2msftngp13.phx.gbl ...您将不得不使用Windows API来制作其他控件滚动
下来。捕获您想要成为主控件的控件的onVScroll事件,并让它向从控件发送消息。
您需要使用User32.DLL并使用发送消息垂直滚动到另一个控件手柄的常数。
HTH
Dino M. Buljubasic <二************* @ rivusglobal.com>在消息中写道
新闻:GK ********************** @ news2.telusplanet.ne t ...我有一个树视图和一个检查列表视图控制一个在另一个旁边。
我想让它们工作,这样当我向下滚动或向上滚动其中一个时,
其他也一样。
任何帮助将不胜感激
-
Dino Buljubasic
软件开发人员
http:// rivusglobal。 com
它们是从Control继承而来的 - 尝试这个 - 我还没试过它树
控制,但这是一个检查列表框的工作示例(这个工作)
问候OHM
--- -------------------------------------------------- -----------------------
------------------- ---------
公共类Form1
继承System.Windows.Forms.Form
私有声明函数SendMessage Lib" user32.dll"别名SendMessageA
(ByVal hWnd As IntPtr,ByVal wMsg as Int32,ByVal wParam As Int32,ByVal
lParam as Int32)As Int32
Const WM_VSCROLL As Int32 =& H115
Const SB_LINEDOWN As Int32 = 1
Const SB_LINEUP As Int32 = 0
#Region" Windows窗体设计器生成的代码
Public Sub New()
MyBase.New()
''Windows窗体设计器需要此调用。
InitializeComponent()
''在InitializeComponent之后添加任何初始化()致电
结束子
''表格覆盖处理以清理组件列表。
受保护的重载覆盖子处理(ByVal处理为布尔值)
如果处置则
如果不是(组件无效)则
components.Dispose()
结束如果
结束如果
MyBase.Dispose(处理)
结束子
''Windows窗体设计师要求
私有组件As System.ComponentModel.IContainer
''注意:Windows窗体设计器需要以下步骤
''可以使用Windows窗体设计器修改它。
''不要使用代码编辑器修改它。
Friend WithEvents PerformVscroll As System.Windows.Forms.Button
Friend WithEvents rtb2 As System.Windows.Forms.RichTextBox
Friend WithEvents ScrollUP As System.Windows .Forms.Button
Friend WithEvents lb1 As System.Windows.Forms.ListBox
< System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.PerformVscroll = New System.Windows.Forms.Button
Me.rtb2 = New System.Windows。 Forms.RichTextBox
Me.ScrollUP =新的System.Windows.Forms.Button
Me.lb1 =新的System.Windows.Forms。 ListBox
Me.SuspendLayout()
''
''PerformVscroll
''
Me.PerformVscroll.Location =新的System.Drawing.Point(216,192)
Me.PerformVscroll.Name =" PerformVscroll"
Me.PerformVscroll.Size = New System.Drawing.Size(104,23)
Me.PerformVscroll.TabIndex = 2
Me.PerformVscroll.Text =向上滚动
''
''rtb2
''
Me.rtb2.Location = New System.Drawing.Point (112,120)
Me.rtb2.Name =" rtb2"
Me.rtb2.TabIndex = 3
Me.rtb2.Text =" RichTextBox1"
''
'' ScrollUP
''
Me.ScrollUP.Location = New System.Drawing.Point(216,120)
Me.ScrollUP.Name =" ScrollUP"
Me.ScrollUP.Size = New System.Drawing.Size(104,23)
Me.ScrollUP.TabIndex = 4
Me.ScrollUP.Text ="向上滚动
' '
''lb1
''
Me.lb1.Items.AddRange( New Object(){" 1"," 2"" 3","""""""""""""""""" b $ b10,11,12,13,14,12,13,14,15})
Me.lb1.Location = New System.Drawing.Point(408,96)
Me.lb1.Name =" lb1"
Me.lb1.S ize = New System.Drawing.Size(120,95)
Me.lb1.TabIndex = 5
''
''Form1
''
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(680,293)
Me.Controls.Add(Me.lb1 )
Me.Controls.Add(Me.ScrollUP)
Me.Controls.Add(Me.rtb2)
Me.Controls.Add(Me.PerformVscroll)
Me.Name =" Form1"
Me .Text =" Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As
System.EventArgs)
Dim ea As New EventArgs
End Sub
Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As
System.EventArgs)处理MyBase.Load
rtb2.ScrollBars = RichTextBoxScrollBars.None
rtb2.Text + =
" RichTextBox1jkhkhgjkhgkjjkhkjhgjghjgjkhkhgjkhgkjj khkjhgjghjgjkhkhgjkhgkjjkh
kjhgjghjgjkhkhgjkhgkjjkhkjhgjghjgjkhkhgjkhgkjjkhkj hgjghjgjkhkhgjkhgkjjkhkjhg <登记/>
jghjgjkhkhgjkhgkjjkhkjhgjghjgjkhkhgjkhgkjjkhkjhgjg hjgjkhkhgjkhgkjjkhkjhgjghj
gjkhkhgjkhgkjjkhkjhgjghjgjkhkhgjkhgkjjkhkjhgjghjgj khkhgjkhgkjjkhkjhgjghjgjkh
khgjkhgkjjkhkjhgjghjgjkhkhgjkhgkjjkhkjhgjghjgjkhkh gjkhgkjjkhkjhgjghjgjkhkhgj
khgkjjkhkjhgjghJJJJJkjjkhkjhgjghjgjkhkhgjkhgkjjkhk jhgjghjgjkhkhgjkhgkjjkhkjh
gjghjgjkhkhgjkhgkjjkhkjhgjghjgjkhkhgjkhgkjjkhkjhgj ghjgjkhkhgjkhgkjjkhkjhgjgh
jgjkhkhgjkhgkjjkhkjhgjghjgjkhkhCCCCCC ******* CCCCCC"
End Sub
Private Sub PerformScroll_Click(ByVal发送者)作为System.Object,ByVal e As
System.EventArgs)处理PerformVscroll.Click
''SendMessage(rtb 2.Handle,WM_VSCROLL,SB_LINEDOWN,0)
SendMessage(lb1.Handle,WM_VSCROLL,SB_LINEDOWN,0)
End Sub
Private Sub handleScroll(ByVal sender As System.Object,ByVal e As
System.EventArgs)处理rtb2.VScroll
Console.WriteLine(" Scrolling")
End Sub
Private Sub ScrollUP_Click(ByVal sender As System.Object,ByVal e作为
System.EventArgs)处理ScrollUP.Click
''SendMessage(rtb2.Handle,WM_VSCROLL,SB_LINEUP,0)
>
SendMessage(lb1.Handle,WM_VSCROLL,SB_LINEUP,0)
结束子
结束班
" Dino M. Buljubasic" <二************* @ rivusglobal.com>在消息中写道
news:b6 ********************** @ news2.telusplanet.ne t ...树视图或选中列表视图没有onVScroll事件。
单手人[OHM] < te *************************** @ BTOpenworld.com>
在留言中写道:%2 **** ************ @ tk2msftngp13.phx.gbl ...你将不得不使用Windows API来进行其他控制
scrolldown。捕获您想要成为主控件的控件的onVScroll事件,并让它向从控件发送消息。
您需要使用User32.DLL并使用发送消息垂直滚动到另一个控件手柄的常数。
HTH
Dino M. Buljubasic <二************* @ rivusglobal.com>在消息中写道
新闻:GK ********************** @ news2.telusplanet.ne t ...我有一个树视图和一个检查列表视图控制一个旁边。
我想让它们工作,以便当我向下或向上滚动其中一个
另一个同样的。
任何帮助将不胜感激
-
Dino Buljubasic
软件开发人员
http://rivusglobal.com
I have a treeview and a checked list view controls one beside another. I
want to make them work so that when I scroll down or up one of them the
other does the same.
Any help will be appreciated
--
Dino Buljubasic
Software Developer
http://rivusglobal.com
解决方案
Your going to have to use the Windows API to make the other control scroll
down. Trap the onVScroll event of the control which you want to be the
master and have it send a message to the slave control.
You need to use the User32.DLL and send a Message using the constant for
vertical scroll to the handle of the other control.
HTH
"Dino M. Buljubasic" <di*************@rivusglobal.com> wrote in message
news:GK**********************@news2.telusplanet.ne t...I have a treeview and a checked list view controls one beside another. I
want to make them work so that when I scroll down or up one of them the
other does the same.
Any help will be appreciated
--
Dino Buljubasic
Software Developer
http://rivusglobal.com
Tree View or Checked List View do not have onVScroll event.
"One Handed Man [ OHM ]" <te***************************@BTOpenworld.com>
wrote in message news:%2****************@tk2msftngp13.phx.gbl...Your going to have to use the Windows API to make the other control scroll
down. Trap the onVScroll event of the control which you want to be the
master and have it send a message to the slave control.
You need to use the User32.DLL and send a Message using the constant for
vertical scroll to the handle of the other control.
HTH
"Dino M. Buljubasic" <di*************@rivusglobal.com> wrote in message
news:GK**********************@news2.telusplanet.ne t...I have a treeview and a checked list view controls one beside another. I want to make them work so that when I scroll down or up one of them the
other does the same.
Any help will be appreciated
--
Dino Buljubasic
Software Developer
http://rivusglobal.com
They are inherited from Control - Try this - I havent tried it for the tree
control but this is a working example for the checked listbox ( This works )
Regards OHM
----------------------------------------------------------------------------
----------------------------
Public Class Form1
Inherits System.Windows.Forms.Form
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA"
(ByVal hWnd As IntPtr, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal
lParam As Int32) As Int32
Const WM_VSCROLL As Int32 = &H115
Const SB_LINEDOWN As Int32 = 1
Const SB_LINEUP As Int32 = 0
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
''This call is required by the Windows Form Designer.
InitializeComponent()
''Add any initialization after the InitializeComponent() call
End Sub
''Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
''Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
''NOTE: The following procedure is required by the Windows Form Designer
''It can be modified using the Windows Form Designer.
''Do not modify it using the code editor.
Friend WithEvents PerformVscroll As System.Windows.Forms.Button
Friend WithEvents rtb2 As System.Windows.Forms.RichTextBox
Friend WithEvents ScrollUP As System.Windows.Forms.Button
Friend WithEvents lb1 As System.Windows.Forms.ListBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.PerformVscroll = New System.Windows.Forms.Button
Me.rtb2 = New System.Windows.Forms.RichTextBox
Me.ScrollUP = New System.Windows.Forms.Button
Me.lb1 = New System.Windows.Forms.ListBox
Me.SuspendLayout()
''
''PerformVscroll
''
Me.PerformVscroll.Location = New System.Drawing.Point(216, 192)
Me.PerformVscroll.Name = "PerformVscroll"
Me.PerformVscroll.Size = New System.Drawing.Size(104, 23)
Me.PerformVscroll.TabIndex = 2
Me.PerformVscroll.Text = "Scroll Up"
''
''rtb2
''
Me.rtb2.Location = New System.Drawing.Point(112, 120)
Me.rtb2.Name = "rtb2"
Me.rtb2.TabIndex = 3
Me.rtb2.Text = "RichTextBox1"
''
''ScrollUP
''
Me.ScrollUP.Location = New System.Drawing.Point(216, 120)
Me.ScrollUP.Name = "ScrollUP"
Me.ScrollUP.Size = New System.Drawing.Size(104, 23)
Me.ScrollUP.TabIndex = 4
Me.ScrollUP.Text = "Scroll UP"
''
''lb1
''
Me.lb1.Items.AddRange(New Object() {"1", "2", "3", "4", "5", "6", "7", "8",
"10", "11", "12", "13", "14", "12", "13", "14", "15"})
Me.lb1.Location = New System.Drawing.Point(408, 96)
Me.lb1.Name = "lb1"
Me.lb1.Size = New System.Drawing.Size(120, 95)
Me.lb1.TabIndex = 5
''
''Form1
''
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(680, 293)
Me.Controls.Add(Me.lb1)
Me.Controls.Add(Me.ScrollUP)
Me.Controls.Add(Me.rtb2)
Me.Controls.Add(Me.PerformVscroll)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Dim ea As New EventArgs
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
rtb2.ScrollBars = RichTextBoxScrollBars.None
rtb2.Text +=
"RichTextBox1jkhkhgjkhgkjjkhkjhgjghjgjkhkhgjkhgkjj khkjhgjghjgjkhkhgjkhgkjjkh
kjhgjghjgjkhkhgjkhgkjjkhkjhgjghjgjkhkhgjkhgkjjkhkj hgjghjgjkhkhgjkhgkjjkhkjhg
jghjgjkhkhgjkhgkjjkhkjhgjghjgjkhkhgjkhgkjjkhkjhgjg hjgjkhkhgjkhgkjjkhkjhgjghj
gjkhkhgjkhgkjjkhkjhgjghjgjkhkhgjkhgkjjkhkjhgjghjgj khkhgjkhgkjjkhkjhgjghjgjkh
khgjkhgkjjkhkjhgjghjgjkhkhgjkhgkjjkhkjhgjghjgjkhkh gjkhgkjjkhkjhgjghjgjkhkhgj
khgkjjkhkjhgjghJJJJJkjjkhkjhgjghjgjkhkhgjkhgkjjkhk jhgjghjgjkhkhgjkhgkjjkhkjh
gjghjgjkhkhgjkhgkjjkhkjhgjghjgjkhkhgjkhgkjjkhkjhgj ghjgjkhkhgjkhgkjjkhkjhgjgh
jgjkhkhgjkhgkjjkhkjhgjghjgjkhkhCCCCCC*******CCCCCC "
End Sub
Private Sub PerformScroll_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles PerformVscroll.Click
''SendMessage(rtb2.Handle, WM_VSCROLL, SB_LINEDOWN, 0)
SendMessage(lb1.Handle, WM_VSCROLL, SB_LINEDOWN, 0)
End Sub
Private Sub handleScroll(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles rtb2.VScroll
Console.WriteLine("Scrolling")
End Sub
Private Sub ScrollUP_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ScrollUP.Click
''SendMessage(rtb2.Handle, WM_VSCROLL, SB_LINEUP, 0)
SendMessage(lb1.Handle, WM_VSCROLL, SB_LINEUP, 0)
End Sub
End Class
"Dino M. Buljubasic" <di*************@rivusglobal.com> wrote in message
news:b6**********************@news2.telusplanet.ne t...Tree View or Checked List View do not have onVScroll event.
"One Handed Man [ OHM ]" <te***************************@BTOpenworld.com>
wrote in message news:%2****************@tk2msftngp13.phx.gbl...Your going to have to use the Windows API to make the other control scrolldown. Trap the onVScroll event of the control which you want to be the
master and have it send a message to the slave control.
You need to use the User32.DLL and send a Message using the constant for
vertical scroll to the handle of the other control.
HTH
"Dino M. Buljubasic" <di*************@rivusglobal.com> wrote in message
news:GK**********************@news2.telusplanet.ne t...I have a treeview and a checked list view controls one beside another.
I want to make them work so that when I scroll down or up one of them the other does the same.
Any help will be appreciated
--
Dino Buljubasic
Software Developer
http://rivusglobal.com
这篇关于滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文