Click here to Skip to main content
15,887,453 members
Home / Discussions / C#
   

C#

 
GeneralRe: Image Resources - What is difference between Local Resource and Project Resource File Pin
shultas19-Aug-09 13:40
shultas19-Aug-09 13:40 
GeneralRe: Image Resources - What is difference between Local Resource and Project Resource File Pin
mustang8619-Aug-09 19:38
mustang8619-Aug-09 19:38 
GeneralRe: Image Resources - What is difference between Local Resource and Project Resource File Pin
btaz12518-Apr-11 16:20
btaz12518-Apr-11 16:20 
QuestionGraphicsPath.AddString Pin
xstoneheartx19-Aug-09 11:42
xstoneheartx19-Aug-09 11:42 
Questionc# text to wav volume Pin
mikeyman419-Aug-09 11:32
mikeyman419-Aug-09 11:32 
AnswerRe: c# text to wav volume Pin
Christian Graus19-Aug-09 15:38
protectorChristian Graus19-Aug-09 15:38 
QuestionConvert GlyphIndex to Unicode Pin
xstoneheartx19-Aug-09 11:30
xstoneheartx19-Aug-09 11:30 
QuestionModeless active window/class - Cannot access a disposed object. Pin
Natural_Demon19-Aug-09 9:05
Natural_Demon19-Aug-09 9:05 
it has problay discussed lots of times before, but i can't find the solution.

private void button1_Click(object sender, EventArgs e)
        {
             Form2 mw2 = new Form2();
             mw2.Show();
        }

this way keeps creating new instances of the same class and therefor new windows/forms.

i would like to do it as in the code below, create only one instance and keep it active and if i like to see it, make it visisble again.
i would like to creatre a sort of test window, where i can see in a richtext what my main class is doing.

thnx for reading in advance.

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Modales_window
{
    public partial class Form1 : Form
    {
        Form2 mw2 = new Form2();

        // Form1 form = (Form1)Application.OpenForms[0];
        // Form2 form2 = (Form2)Application.OpenForms[1];

        public Form1()
        {
            mw2.closingeventhandler += new Form2.ClosingEventHandler(mw2_closingeventhandler);
            InitializeComponent();
        }
        void mw2_closingeventhandler()
        {
            //mw2.Dispose();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // Cannot access a disposed object.
            // Object name: 'Form2'.
            if (!mw2.Created)
            {
                mw2.Show();
            }
            else
            {
                MessageBox.Show("already open", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = Application.OpenForms.Count.ToString();
        }
}


http://www.codeproject.com/Messages/3043750/Re-two-forms.aspx[^]

Bad = knowing 2 much

AnswerRe: Modeless active window/class - Cannot access a disposed object. Pin
Christian Graus19-Aug-09 11:04
protectorChristian Graus19-Aug-09 11:04 
GeneralRe: Modeless active window/class - Cannot access a disposed object. Pin
Natural_Demon19-Aug-09 12:36
Natural_Demon19-Aug-09 12:36 
GeneralRe: Modeless active window/class - Cannot access a disposed object. Pin
Natural_Demon19-Aug-09 13:00
Natural_Demon19-Aug-09 13:00 
GeneralRe: Modeless active window/class - Cannot access a disposed object. Pin
Christian Graus19-Aug-09 16:00
protectorChristian Graus19-Aug-09 16:00 
GeneralRe: Modeless active window/class - Cannot access a disposed object. Pin
Natural_Demon20-Aug-09 2:48
Natural_Demon20-Aug-09 2:48 
QuestionDynamic Menu Creation Problem Pin
jroberson1019-Aug-09 8:59
jroberson1019-Aug-09 8:59 
AnswerRe: Dynamic Menu Creation Problem Pin
Hristo-Bojilov19-Aug-09 9:37
Hristo-Bojilov19-Aug-09 9:37 
GeneralRe: Dynamic Menu Creation Problem Pin
jroberson1019-Aug-09 9:41
jroberson1019-Aug-09 9:41 
GeneralRe: Dynamic Menu Creation Problem Pin
Hristo-Bojilov19-Aug-09 9:46
Hristo-Bojilov19-Aug-09 9:46 
GeneralRe: Dynamic Menu Creation Problem Pin
jroberson1019-Aug-09 9:50
jroberson1019-Aug-09 9:50 
GeneralRe: Dynamic Menu Creation Problem Pin
Hristo-Bojilov19-Aug-09 9:56
Hristo-Bojilov19-Aug-09 9:56 
GeneralRe: Dynamic Menu Creation Problem Pin
jroberson1019-Aug-09 10:07
jroberson1019-Aug-09 10:07 
GeneralRe: Dynamic Menu Creation Problem Pin
jroberson1020-Aug-09 11:36
jroberson1020-Aug-09 11:36 
GeneralRe: Dynamic Menu Creation Problem Pin
0x3c019-Aug-09 9:47
0x3c019-Aug-09 9:47 
GeneralRe: Dynamic Menu Creation Problem Pin
jroberson1019-Aug-09 9:51
jroberson1019-Aug-09 9:51 
GeneralRe: Dynamic Menu Creation Problem Pin
0x3c019-Aug-09 9:58
0x3c019-Aug-09 9:58 
QuestionInsert function into event at runtime Pin
bonzaiholding19-Aug-09 8:45
bonzaiholding19-Aug-09 8:45 

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.