datagridview cell click event

You will also need to check the cell clicked is not the column header cell. Like this:

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
    if (dataGridView1.CurrentCell.ColumnIndex.Equals(3) && e.RowIndex != -1){
        if (dataGridView1.CurrentCell != null && dataGridView1.CurrentCell.Value != null)
            MessageBox.Show(dataGridView1.CurrentCell.Value.ToString());   
}

Check that CurrentCell.RowIndex isn't the header row index.


private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{    
    if (e.RowIndex == -1) return; //check if row index is not selected
        if (dataGridView1.CurrentCell.ColumnIndex.Equals(3))
            if (dataGridView1.CurrentCell != null && dataGridView1.CurrentCell.Value != null)
                MessageBox.Show(dataGridView1.CurrentCell.Value.ToString());
}