Splitter.SplitterMoving 事件

定義

發生於分隔器控制項在移動的過程中時。 SplitterMoving 已經由 SplitterMoving 所取代,而提供它的目的只是為了要保有與舊版之間的相容性。

public:
 event System::Windows::Forms::SplitterEventHandler ^ SplitterMoving;
public event System.Windows.Forms.SplitterEventHandler SplitterMoving;
public event System.Windows.Forms.SplitterEventHandler? SplitterMoving;
member this.SplitterMoving : System.Windows.Forms.SplitterEventHandler 
Public Custom Event SplitterMoving As SplitterEventHandler 

事件類型

範例

下列程式碼範例示範如何使用這個成員。 在此範例中,事件處理常式會報告事件的發生次數 SplitterMoving 。 此報告可協助您瞭解事件發生的時間,並可協助您進行偵錯。 若要報告多個事件或經常發生的事件,請考慮將 取代 MessageBox.ShowConsole.WriteLine 或將訊息附加至多行 TextBox

若要執行範例程式碼,請將它貼入包含名為 Splitter1 之類型 Splitter 實例的專案。 然後,確定事件處理常式與 事件相關聯 SplitterMoving

private void Splitter1_SplitterMoving(Object sender, SplitterEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "X", e.X );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Y", e.Y );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "SplitX", e.SplitX );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "SplitY", e.SplitY );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "SplitterMoving Event" );
}
Private Sub Splitter1_SplitterMoving(sender as Object, e as SplitterEventArgs) _ 
     Handles Splitter1.SplitterMoving

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "X", e.X)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Y", e.Y)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "SplitX", e.SplitX)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "SplitY", e.SplitY)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"SplitterMoving Event")

End Sub

備註

您可以為事件建立事件處理常式, SplitterMoving 以在應用程式中執行調整大小驗證。 例如,如果 Splitter 控制項停駐在控制項 ListView 和控制項的 TreeView 邊緣,您可以在 事件中 SplitterMoved 撰寫程式碼,以判斷 和 ListView 控制項的最小和/或大小上限 TreeView 是否已超過,並將控制項的大小調整為其最小或最大大小。

如需處理事件的詳細資訊,請參閱 處理和引發事件

適用於

另請參閱