Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Problem with accessing Forms
I have an app that will use multiple forms, upon the program running the initial form, I want to to create a 2nd form, but not display it until a user clicks on a button on Form1. Sounds simple enough? Where I'm having problems is with the compiler deciding that this other form doesn't exist in the current context.
public partial class Form1 : Form
MyFormClass MyForm = new MyFormClass();
private void buttonCardIndex_Click(object sender, EventArgs e)
The compiler tells me that MyForm.Show() [italic]does not exist in the current context[/italic], but it must do because if I put this line underneath the line that creates it, it works. What I don't understand is why I can't reference it from the button click as the form must exist because it's created when Form1 is run.
I'm guessing I'm doing something silly, but I can't work out what.
0 · ·