Hey Rob,
No worries, glad to hear everything is going well.
When you have created your Players class on Form1, it's just like creating any class, whether it be a string, an int, or anything else, it now "belongs" to Form1, so if you create Form2, it doesn't know anything about your players class.
There are a few ways of solving this, here would be my two options:
1) Create a static class that contains your Players class variable.. this way this class can be accessed from anywhere in the application and updated/read from whenever you want... we can chat about this a bit more if you decide to go down that route
2) This is the simpler option, however it has it's limits. Which is to pass your existing players class into your new form. This really only suits if you want to read from this class, as if you want to change/update it's values and then use those again in other places, it can be a bit trickey.
to do this, go to the constructor of your "Form2", add a players variable for this form and allow it to accept a Players class, i.e.
-
public partial class frmForm2 : Form
-
{
-
Players pMyPlayersClass; //This is a players class belonging to THIS form
-
-
public frmForm2(Players myPassedPlayersClass)
-
{
-
//Here we are accepting the class from Form1
-
//and filling this form's players class with the info
-
//so it can be accessed once this constructor is finished
-
-
pMyPlayersClass = myPassedPlayersClass;
-
}
-
So now your second form has a copy of the first players class, all it's properties and methods
You simply pass the value into it as follows:
-
//Somewhere on Form1
-
frmForm2 myForm2 = new frmForm2(myOriginalPlayersClass);
-
myForm2.Show();
-
Hope that helps,
Just remember that this is a COPY of the original Players, and not the original, so if you change something in the Form2 one (like delete a player) then close that form, it will not be deleted in the Players on Form1. If you want to reflect changes like that, we need to use Option 1.
Let me know if you want to try option 1 and need help with it.
Mark