Question: I have tried to get an answer to this but so far no help has been able to do what I want it to.

I have this piece of code, which is meant to look at the selected row and output it's columns into the corresponding text boxes.

```
 private void DataGridView01_SelectionChanged(object sender, EventArgs e)
 {
    if (DataGridView01.SelectedRows.Count > 0)
    {
       personIDTextBox.Text = DataGridView01.SelectedRows[0].Cells[0].Value.ToString();
       comboBox1.Text = DataGridView01.SelectedRows[0].Cells[1].Value.ToString();
       Txt_FirstName.Text = DataGridView01.SelectedRows[0].Cells[2].Value.ToString();
       mIDDLENAMETextBox.Text = DataGridView01.SelectedRows[0].Cells[3].Value.ToString();
       sURNAMETextBox.Text = DataGridView01.SelectedRows[0].Cells[4].Value.ToString();
       cITYTextBox.Text = DataGridView01.SelectedRows[0].Cells[5].Value.ToString();
       eMAILTextBox.Text = DataGridView01.SelectedRows[0].Cells[6].Value.ToString();
     }
  }

```

When I launch the program, I get no errors but it doesn't output the data into the textbox. Anyone know what I am doing wrong?

Answer: 
HOOKING UP EVENTS:

It is the most basic thing you need to learn to code in VS. In short it means that the event name, here `DataGridView01_SelectionChanged` is connected to the event. To do so one can either use code or one inserts it into the correct slot of the events pane of the property tab. Select the `DataGridView`, open the events pane (the one with the flash) and locate the SelectionChanged event! Here insert the name of the event and you are done.

[![enter image description here](https://i.stack.imgur.com/u7cQM.png)](https://i.stack.imgur.com/u7cQM.png)

(I only have the German versions of VS installed..)

The result is reflected in the form\_designer.cs file and it is the same thing (in reverse) as double clicking that spot and then filling in the generated code stub.. 

Controls have many events; one is the **default** event and this can be generated by **double clicking** the control itself in the designer. But eventually you will need all 3 ways to **generate** and **hook up** the events, (as well as sometimes removing them.)
If you want to display the datagridview selected rows into corresponding textboxes, fine the below steps ,

**Step 1:** 
1. Change the DataGridView Selection mode to **FullRowSelect** in Datagridview property.
2. Create the cell click event in Data grid view using property.
[enter image description here](https://i.stack.imgur.com/E6RaI.jpg)
3. Write the below code and test it, It may helpful

```
private void DataGridView01_CellClick(object sender,DataGridViewCellEventArgs e)
{
if (DataGridView01.Rows.Count > -1)
{
PersonIdTextBox.Text=DataGridView01.Rows[e.RowIndex].Cells[0].Value.ToString();
comboBox1.Text = DataGridView01.Rows[e.RowIndex].Cells[1].Value.ToString();
Txt_FirstName.Text = DataGridView01.Rows[e.RowIndex].Cells[2].Value.ToString();
 mIDDLENAMETextBox.Text = DataGridView01.Rows[e.RowIndex].Cells[3].Value.ToString();
sURNAMETextBox.Text = DataGridView01.Rows[e.RowIndex].Cells[4].Value.ToString();
cITYTextBox.Text = DataGridView01.Rows[e.RowIndex].Cells[5].Value.ToString();
eMAILTextBox.Text = DataGridView01.Rows[e.RowIndex].Cells[6].Value.ToString();

}
}

```