Click here to Skip to main content
16,006,065 members
Home / Discussions / C#
   

C#

 
AnswerRe: Creating Controls Dynamically using a For Loop? Pin
Christian Graus23-Aug-05 18:40
protectorChristian Graus23-Aug-05 18:40 
AnswerRe: Creating Controls Dynamically using a For Loop? Pin
Luis Alonso Ramos23-Aug-05 19:35
Luis Alonso Ramos23-Aug-05 19:35 
Generalmanaging the calendar Pin
lynnafna23-Aug-05 17:27
lynnafna23-Aug-05 17:27 
GeneralRetrieve and change email account settings Outlook Pin
23-Aug-05 16:21
suss23-Aug-05 16:21 
Generalpassing datareader to a User control Pin
dotcomcrash200523-Aug-05 15:36
dotcomcrash200523-Aug-05 15:36 
GeneralRe: passing datareader to a User control Pin
tiger200523-Aug-05 16:52
tiger200523-Aug-05 16:52 
GeneralProblem with Form Dispose please help Pin
Darktaz23-Aug-05 13:03
Darktaz23-Aug-05 13:03 
GeneralRe: Problem with Form Dispose please help Pin
David Stone23-Aug-05 13:26
sitebuilderDavid Stone23-Aug-05 13:26 
It sounds like you're declaring frm2 within your click handler and then calling it again once the object has gone out of scope. My suggestion would be to promote frm2 to a local variable and then instantiate it in the constructor. Then, when you handle your button click event, you can call Show(). Try something like this:

public class Form1
{
    Form2 myForm2;
    Button myButton;
    public Form1()
    {
        myForm2 = new Form2();

        myButton = new Button();
        myButton.Click += new EventHandler(myButton_Click);
    }

    private void myButton_Click(object sender, EventArgs e)
    {
        myForm2.Show();
    }
}



[Cheshire] I can't afford those plastic things to cover the electric sockets so I just draw bunny faces on the electric outlets to scare the kids away from them...
[RLtim] Newsflash! Kids aren't afraid of bunnies.
[Cheshire] Oh they will be...
-Bash.org

GeneralRe: Problem with Form Dispose please help Pin
Darktaz23-Aug-05 13:45
Darktaz23-Aug-05 13:45 
GeneralRe: Problem with Form Dispose please help Pin
tiger200523-Aug-05 14:49
tiger200523-Aug-05 14:49 
GeneralRe: Problem with Form Dispose please help Pin
Darktaz23-Aug-05 15:12
Darktaz23-Aug-05 15:12 
Generalusing rasapi32 for PPPoE :~ Pin
devitj23-Aug-05 11:24
devitj23-Aug-05 11:24 
GeneralEmail in C# 2005 (.net 2.0) Pin
Daniel132423-Aug-05 11:24
Daniel132423-Aug-05 11:24 
GeneralRe: Email in C# 2005 (.net 2.0) Pin
Guffa23-Aug-05 12:15
Guffa23-Aug-05 12:15 
GeneralRe: Email in C# 2005 (.net 2.0) Pin
David Stone23-Aug-05 12:33
sitebuilderDavid Stone23-Aug-05 12:33 
GeneralRe: Email in C# 2005 (.net 2.0) Pin
Guffa23-Aug-05 12:53
Guffa23-Aug-05 12:53 
GeneralRe: Email in C# 2005 (.net 2.0) Pin
Daniel132423-Aug-05 13:14
Daniel132423-Aug-05 13:14 
GeneralRe: Email in C# 2005 (.net 2.0) Pin
Daniel132423-Aug-05 13:29
Daniel132423-Aug-05 13:29 
GeneralRe: Email in C# 2005 (.net 2.0) Pin
David Stone23-Aug-05 12:34
sitebuilderDavid Stone23-Aug-05 12:34 
GeneralRe: Email in C# 2005 (.net 2.0) Pin
senorbadger10-Mar-09 7:12
senorbadger10-Mar-09 7:12 
QuestionHow to copy struct to byte [] ? Pin
queisser23-Aug-05 11:04
queisser23-Aug-05 11:04 
AnswerRe: How to copy struct to byte [] ? Pin
Bojan Rajkovic23-Aug-05 19:44
Bojan Rajkovic23-Aug-05 19:44 
AnswerRe: How to copy struct to byte [] ? Pin
leppie23-Aug-05 21:47
leppie23-Aug-05 21:47 
GeneralSelection Frames Pin
Shawn Dwyer23-Aug-05 10:06
Shawn Dwyer23-Aug-05 10:06 
GeneralDatagrid help! Pin
dgap23-Aug-05 8:27
dgap23-Aug-05 8:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.