i have 2 form in my media player project i have make object of from1 (parent form) and by that get value from form1 in form3. but i also need to get value of a variable from form3 to form1. but the problem is that when i make the object of form3 in form1 like this
Form3 m_child;
public Form1(Form3 frm3)
{
InitializeComponent();
m_child = frm3;
}
it shows the error in the program.cs that from1 does not contain a constructor that contain 0 argument. i know i have to pass there a parameter in Application.Run(new Form1());
but what i should pass i have no idea. plz help if is there any solution or any other way to get the value from child to parent form.
this is my code for form3 now i want to use value of smileplay, surpriseplay ,sadplay,normalplay,ambiguousplay in form1
Form1 m_parent;
public Form3(Form1 frm1)
{
InitializeComponent();
m_parent = frm1;
}
private void Form3_Load(object sender, EventArgs e)
{
WMPLib.IWMPPlaylistArray allplaylist= m_parent.axWindowsMediaPlayer1.playlistCollection.getAll();
for (int litem = 0; litem < allplaylist.count; litem++)
{
smilecombo.Items.Add( allplaylist.Item(litem).name);
surprisecombo.Items.Add(allplaylist.Item(litem).name);
sadcombo.Items.Add(allplaylist.Item(litem).name);
normalcombo.Items.Add(allplaylist.Item(litem).name);
ambiguouscombo.Items.Add(allplaylist.Item(litem).name);
}
}
private void savebtn_Click(object sender, EventArgs e)
{
WMPLib.IWMPPlaylist smileplay= m_parent.axWindowsMediaPlayer1.playlistCollection.getByName(smilecombo.SelectedItem.ToString()).Item(0);
WMPLib.IWMPPlaylist surpriseplay = m_parent.axWindowsMediaPlayer1.playlistCollection.getByName(surprisecombo.SelectedItem.ToString()).Item(0);
WMPLib.IWMPPlaylist sadplay = m_parent.axWindowsMediaPlayer1.playlistCollection.getByName(sadcombo.SelectedItem.ToString()).Item(0);
WMPLib.IWMPPlaylist normalplay = m_parent.axWindowsMediaPlayer1.playlistCollection.getByName(normalcombo.SelectedItem.ToString()).Item(0);
WMPLib.IWMPPlaylist ambiguousplay = m_parent.axWindowsMediaPlayer1.playlistCollection.getByName(ambiguouscombo.SelectedItem.ToString()).Item(0);
}
I would add a new constructor.
Then
Application.Run(new Form1());
will work just fine.You need to supply Form3 object when initializing form1
Something like:
Or the easy way will be to create two new empty Constructor. In C# when you create a constructor you loose default constructor.
Add these two constructors: