how do i automate a click event

Peter 1 Reputation point
2021-01-11T12:25:06.777+00:00

I would appreciate some help. I am trying to automate a program that requires a click event in a DataGridView . Here is a copy of the event.

Private Sub DataGridView1_CellContentClick(sender As Object,
e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick

    If e.ColumnIndex = 6 Then

        Dim runnerForm As New runnerForm(DataGridView1.Item("runnerName", e.RowIndex).Value _
            & " - " & DataGridView1.Item("marketStartTime", e.RowIndex).Value & " " &
            DataGridView1.Item("course", e.RowIndex).Value,
                           DataGridView1.Item("marketId", e.RowIndex).Value,
                           DataGridView1.Item("selectionId", e.RowIndex).Value)

        runnerFormDictionary.Add(DataGridView1.Item("selectionId", e.RowIndex).Value,
                             runnerForm)

    End If

End Sub
Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,898 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Daniel Zhang-MSFT 9,626 Reputation points
    2021-01-12T09:57:56.323+00:00

    Hi Peter-4215,
    What is your program? And how do you automate it?
    what is "runnerForm"and “runnerFormDictionary” in your code?
    According to my understanding, you can call the DataGridView.CellContentClick event in your automated method.
    And you can also put the logic in CellContentClick event to a method and call this method automatically.
    Reza Aghaei has provided a similar code example in this thread and you can refer to it.
    Best Regards,
    Daniel Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.