DataGridView.CellMouseUp Zdarzenie

Definicja

Występuje, gdy użytkownik zwolni przycisk myszy na komórce.

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

Typ zdarzenia

Przykłady

Poniższy przykład kodu przedstawia użycie tego elementu członkowskiego. W tym przykładzie program obsługi zdarzeń zgłasza wystąpienie zdarzenia CellMouseUp . Ten raport pomaga dowiedzieć się, kiedy wystąpi zdarzenie i może pomóc w debugowaniu. Aby zgłosić wiele zdarzeń lub zdarzeń, które występują często, rozważ zastąpienie MessageBox.Show komunikatu ciągiem Console.WriteLine lub dołączeniem go do wielowierszowego TextBoxelementu .

Aby uruchomić przykładowy kod, wklej go w projekcie zawierającym wystąpienie typu DataGridView o nazwie DataGridView1. Następnie upewnij się, że program obsługi zdarzeń jest skojarzony ze zdarzeniem CellMouseUp .

private void DataGridView1_CellMouseUp(Object sender, DataGridViewCellMouseEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "ColumnIndex", e.ColumnIndex );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "RowIndex", e.RowIndex );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Button", e.Button );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Clicks", e.Clicks );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "X", e.X );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Y", e.Y );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Delta", e.Delta );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Location", e.Location );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "CellMouseUp Event" );
}
Private Sub DataGridView1_CellMouseUp(sender as Object, e as DataGridViewCellMouseEventArgs) _ 
     Handles DataGridView1.CellMouseUp

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "ColumnIndex", e.ColumnIndex)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "RowIndex", e.RowIndex)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Button", e.Button)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Clicks", e.Clicks)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "X", e.X)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Y", e.Y)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Delta", e.Delta)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Location", e.Location)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"CellMouseUp Event")

End Sub

Uwagi

To zdarzenie występuje, gdy użytkownik zwalnia dowolne przyciski myszy. Użyj właściwości , MouseEventArgs.Button aby określić, który przycisk został kliknięty.

Aby uzyskać więcej informacji na temat obsługi zdarzeń, zobacz Obsługa i podnoszenie zdarzeń.

Dotyczy

Zobacz też