DataGridViewCell.OnMouseClick(DataGridViewCellMouseEventArgs) Méthode

Définition

Appelée quand l’utilisateur clique avec un bouton de la souris pendant que le pointeur se trouve sur une cellule.Called when the user clicks a mouse button while the pointer is on a cell.

protected:
 virtual void OnMouseClick(System::Windows::Forms::DataGridViewCellMouseEventArgs ^ e);
protected virtual void OnMouseClick (System.Windows.Forms.DataGridViewCellMouseEventArgs e);
abstract member OnMouseClick : System.Windows.Forms.DataGridViewCellMouseEventArgs -> unit
override this.OnMouseClick : System.Windows.Forms.DataGridViewCellMouseEventArgs -> unit
Protected Overridable Sub OnMouseClick (e As DataGridViewCellMouseEventArgs)

Paramètres

e
DataGridViewCellMouseEventArgs

DataGridViewCellMouseEventArgs qui contient les données d'événement.A DataGridViewCellMouseEventArgs that contains the event data.

Exemples

L’exemple de code suivant illustre l’utilisation de cette méthode.The following code example demonstrates the use of this method.

// Override OnMouseClick in a class derived from DataGridViewCell to 
// enter edit mode when the user clicks the cell. 
protected override void OnMouseClick(DataGridViewCellMouseEventArgs e)
{
    if (base.DataGridView != null)
    {
        Point point1 = base.DataGridView.CurrentCellAddress;
        if (point1.X == e.ColumnIndex &&
            point1.Y == e.RowIndex &&
            e.Button == MouseButtons.Left &&
            base.DataGridView.EditMode !=
            DataGridViewEditMode.EditProgrammatically)
        {
            base.DataGridView.BeginEdit(true);
        }
    }
}
' Override OnMouseClick in a class derived from DataGridViewCell to 
' enter edit mode when the user clicks the cell. 
Protected Overrides Sub OnMouseClick( _
    ByVal e As DataGridViewCellMouseEventArgs)

    If MyBase.DataGridView IsNot Nothing Then

        Dim point1 As Point = MyBase.DataGridView.CurrentCellAddress
        If point1.X = e.ColumnIndex And _
            point1.Y = e.RowIndex And _
            e.Button = MouseButtons.Left And _
            Not MyBase.DataGridView.EditMode = _
            DataGridViewEditMode.EditProgrammatically Then

            MyBase.DataGridView.BeginEdit(True)

        End If
    End If
End Sub

Remarques

Cette méthode est similaire à la méthode DataGridView.OnCellMouseClick.This method is similar to the DataGridView.OnCellMouseClick method. Elle est appelée dans les mêmes circonstances que le déclenchement d’un événement DataGridView.CellMouseClick, mais ne déclenche pas réellement l’événement.It is called in the same circumstances in which a DataGridView.CellMouseClick event is raised, but it does not actually raise the event.

S’applique à

Voir aussi