private void moviesGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
    MovieDetailsForm form = new MovieDetailsForm(MovieDetailsForm.MovieViewMode.Read);
       
    if (e.ColumnIndex==5)
    {
         form.ShowDialog();
    }
}

I am trying to view the details of a movie when I press the view details button in the datagridview but for some reason I can't get it to work. The place of the buttons in the datagridview is 5.

I'd show a ss but unfortunately I cant, yet.

See this answer as to how to How to handle click event in Button Column in Datagridview? for a good overview of what to do. So long as you only have a single button, you actually don't have to specify the column index at all, which makes your code less fragile to change. Although, Chris is right, that indexes are zero based so you'd need a ColumnIndex of 4 to get the 5th column. You also don't have to new up your form unless you actually want to show it, so I'd move the declaration into the if statement like this:

<!-- language: lang-cs -->
private void moviesGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
	//make sure click not on header and column is type of ButtonColumn
	if (e.RowIndex >= 0 && ((DataGridView)sender).Columns[e.ColumnIndex].GetType() ==  _
						   typeof(DataGridViewButtonColumn))
	{
		 MovieDetailsForm form = new MovieDetailsForm(MovieDetailsForm.MovieViewMode.Read);
		 form.ShowDialog();
	}
}