1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
// Ici tu vas récupérer le titre du film
string LibelleFilm = (string)this.dataGridView1.Rows[e.RowIndex].Cells["TitreFilm"].Value.ToString();
// Sachant que tu vas mettre les films dans le même répertoire par exemple
// Tu vas construire le chemin du film à lancer à partir du titre de ce dernier
string CheminFilm = @"c:\CheminsDeMesFilms\" + LibelleFilm + ".avi";
StratMovie(CheminFilm);
}
private void StratMovie(string CheminFilm)
{
System.Diagnostics.Process p;
System.IO.FileInfo file = new System.IO.FileInfo(CheminFilm);
try
{
if (file.Exists)
{
p = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo pInfo = new System.Diagnostics.ProcessStartInfo(CheminFilm);
//pInfo.UseShellExecute = false;
p.StartInfo = pInfo;
p.Start();
p.Close();
}
else
MessageBox.Show("Le film n'existe pas");
}
catch (Exception)
{
throw;
}
} |
Partager