I want to programmatically generate a click on a DataGridView Row in C#

Simply call the event handler method e.g.:

datagridviewRowClickedEventHandler(new object(), new eventargs());

If you use the sender or e parameters in the event handler then you will need to work out how to pass in the correct values.


Insert the follwing code into your project where appropriate (Usually on the form which has the datagridview).
Make sure to change the name of the DataGridView from dataGridView1 to the appropriate one on your form.

private void Form1_Load(object sender, EventArgs e)
{
    //call the cell click event with the first cell as the parameters.
    dataGridView1_CellClick(dataGridView1, new DataGridViewCellEventArgs(0, 0));
}

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
    //put your code for handling cell click here
}