Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

open a file with listBox C#

$
0
0

Hi,

I want to open several .mp4 files from a listBox1, but it won't work some how..

The code: 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;

namespace WindowsFormsApplication46
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        

        private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            
           Form2 myForm2 = new Form2();

           if (listBox1.SelectedItem == "A")

               openFileDialog1.FileName = @"C://A.mp4";


           Process.Start(openFileDialog1.FileName);


           if (listBox1.SelectedItem == "B")

               openFileDialog1.FileName = @"C://B.mp4";

           Process.Start(openFileDialog1.FileName);
        }


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>