Advertisement

c# beginneer programmer

Started by May 18, 2017 11:54 PM
1 comment, last by ary4n 7 years, 6 months ago

Help me!

I am trying to pass a video between forms.

i created 2 forms and i added button1,button2, listbox1, openfiledialog1 in first form and then i added just a media player in second form. I press button1 and select video then press button2 and the video opens in form2 but i can't do this :( :(

This is Form1


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.IO;

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

        public void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();

            OpenFileDialog filedialog = new OpenFileDialog();
            
            if (filedialog.ShowDialog() == DialogResult.OK)
                
            {
                
                FileInfo dosyabilgisi = new FileInfo(filedialog.FileName);

               listBox1.Items.Add("" + dosyabilgisi.Name);

            }
            

        }

        public void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            axWindowsMediaPlayer1.URL = openFileDialog1.FileName;
        
        
                }

        public void Form1_Load(object sender, EventArgs e)
        {
            axWindowsMediaPlayer1.settings.autoStart = false;

        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            axWindowsMediaPlayer1.Ctlcontrols.play();
           
        }
    }
}

And this is form2


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;

namespace lord
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
           
        }
    }
}

Form2 is empty :) Show me the way out.

video opens in form2 but i can't do this

Can't do what?

Advertisement

maybe you should set the visibility of video player on the second form to "public"

then in form 1 after clicking button2 you should write:


Form2 frm2 = new Form2();


frm2.videoPlayer1.video = some video; // i don't know which component you are using but in here set the video on the second form

// and if you wanted form 2 to be loaded as a dialog :

if(frm2.ShowDialog() == DialogResult.Ok){
 // do somthing
}

I guess this was the answer? or something else you desired?

This topic is closed to new replies.

Advertisement