Splitter.SplitterMoving 事件

定義

發生於分隔器控制項在移動的過程中時。Occurs when the splitter control is in the process of moving. SplitterMoving 已經由 SplitterMoving 所取代,而提供它的目的只是為了要保有與舊版之間的相容性。SplitterMoving has been replaced by SplitterMoving and is provided only for compatibility with previous versions.

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 

範例

下列程式碼範例示範如何使用這個成員。The following code example demonstrates the use of this member. 在此範例中,事件處理常式會報告 SplitterMoving 事件的發生。In the example, an event handler reports on the occurrence of the SplitterMoving event. 此報表可協助您瞭解事件發生的時間,並可協助您進行調試。This report helps you to learn when the event occurs and can assist you in debugging. 若要報告多個事件或經常發生的事件,請考慮使用 Console.WriteLine 取代 MessageBox.Show,或將訊息附加到多行 TextBoxTo report on multiple events or on events that occur frequently, consider replacing MessageBox.Show with Console.WriteLine or appending the message to a multiline TextBox.

若要執行範例程式碼,請將它貼入專案,其中包含名為 Splitter1Splitter 類型的實例。To run the example code, paste it into a project that contains an instance of type Splitter named Splitter1. 然後確定事件處理常式與 SplitterMoving 事件相關聯。Then ensure that the event handler is associated with the SplitterMoving event.

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 事件的事件處理常式,以在您的應用程式中執行調整大小驗證。You can create an event handler for the SplitterMoving event to perform resize validation in your application. 例如,如果 Splitter 控制項停駐在 TreeView 控制項和 ListView 控制項的邊緣,您可以在 SplitterMoved 事件中撰寫程式碼,以判斷是否已超過 TreeViewListView 控制項的最小和/或最大大小,並將控制項大小限制為最小或最大值。For example, if a Splitter control is docked to the edges of a TreeView control and a ListView control, you can write code in the SplitterMoved event to determine if the minimum and/or maximum size for the TreeView and ListView controls has been exceeded and restrict the resizing of the controls to their minimum or maximum size.

如需處理事件的詳細資訊,請參閱處理和引發事件For more information about handling events, see Handling and Raising Events.

適用於

另請參閱