Open a form?
-
Hi, why doesn't my code work? I have two forms in my windows application, I want the user to click on a button called btnCustomize and the other form (called frmCustomize) to open. The first form is called reminder. Here is the code that I have tried : private void btnCustomize_Click(object sender, EventArgs e) { frmCustomize.Show(); } I have also tried variations on this like .ShowDialog(); and such. Can you help?
-
Hi, why doesn't my code work? I have two forms in my windows application, I want the user to click on a button called btnCustomize and the other form (called frmCustomize) to open. The first form is called reminder. Here is the code that I have tried : private void btnCustomize_Click(object sender, EventArgs e) { frmCustomize.Show(); } I have also tried variations on this like .ShowDialog(); and such. Can you help?
Wolf92 wrote:
why doesn't my code work?
What exactly does that mean? Are you getting any exceptions? Did you eventually forget to create an instance of the form and assign it to the frmCustomize field.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
-
Wolf92 wrote:
why doesn't my code work?
What exactly does that mean? Are you getting any exceptions? Did you eventually forget to create an instance of the form and assign it to the frmCustomize field.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
I think I am typing in the wrong code? I want that when the user clicks 'btnCustomize' the form 'frmCustomize' displays. What is the code for this? This is the error message I get when I type in : private void btnCustomize_Click(object sender, EventArgs e) { frmCustomize.Show(); } It says : Error 1 An object reference is required for the nonstatic field, method, or property 'System.Windows.Forms.Control.Show()' D:\Documents and Settings\Sophie\My Documents\Programming\Programs\C#\Reminder\Reminder\reminder.cs 66 13 Reminder
-
I think I am typing in the wrong code? I want that when the user clicks 'btnCustomize' the form 'frmCustomize' displays. What is the code for this? This is the error message I get when I type in : private void btnCustomize_Click(object sender, EventArgs e) { frmCustomize.Show(); } It says : Error 1 An object reference is required for the nonstatic field, method, or property 'System.Windows.Forms.Control.Show()' D:\Documents and Settings\Sophie\My Documents\Programming\Programs\C#\Reminder\Reminder\reminder.cs 66 13 Reminder
You have to create an instance of your custom form on which you can call Show afterwards.
MyForm myFormInstance = new MyForm();
myFormInstance.Show();I suggest you do some reading on OOP.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
-
You have to create an instance of your custom form on which you can call Show afterwards.
MyForm myFormInstance = new MyForm();
myFormInstance.Show();I suggest you do some reading on OOP.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
-
Stefan Troschütz wrote:
I suggest you do some reading on OOP
that right cuase when u work with C# u should look to everything form OOP view the form u created is a class inherteted form WindosForm class and all other objects r the same