ScrollEventArgs.ScrollOrientation 属性

定义

获取引发 Scroll 事件的滚动条方向。

public:
 property System::Windows::Forms::ScrollOrientation ScrollOrientation { System::Windows::Forms::ScrollOrientation get(); };
public System.Windows.Forms.ScrollOrientation ScrollOrientation { get; }
member this.ScrollOrientation : System.Windows.Forms.ScrollOrientation
Public ReadOnly Property ScrollOrientation As ScrollOrientation

属性值

ScrollOrientation 值之一。

示例

下面的代码示例演示了此成员的用法。 在此示例中,事件处理程序报告事件的发生情况 ScrollableControl.Scroll 。 此报告可帮助你了解事件发生的时间,并可以帮助你进行调试。 若要报告多个事件或频繁发生的事件,请考虑将 MessageBox.ShowConsole.WriteLine 消息替换为 或将消息追加到多行 TextBox

若要运行示例代码,请将其粘贴到包含继承自 ScrollableControl的类型的实例(如 PanelContainerControl)的项目中。 然后命名实例 ScrollableControl1 并确保事件处理程序与事件 ScrollableControl.Scroll 相关联。

private void ScrollableControl1_Scroll(Object sender, ScrollEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "ScrollOrientation", e.ScrollOrientation );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Type", e.Type );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "NewValue", e.NewValue );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "OldValue", e.OldValue );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "Scroll Event" );
}
Private Sub ScrollableControl1_Scroll(sender as Object, e as ScrollEventArgs) _ 
     Handles ScrollableControl1.Scroll

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "ScrollOrientation", e.ScrollOrientation)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Type", e.Type)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "NewValue", e.NewValue)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "OldValue", e.OldValue)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"Scroll Event")

End Sub

注解

通常使用 ScrollOrientation 属性来确定引发 Scroll 事件的滚动条方向,例如与 事件一起 ScrollableControl.Scroll

适用于