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

C#

 
AnswerRe: SelectAll - not working on a maskededitbox Pin
tcss10-May-07 0:44
tcss10-May-07 0:44 
QuestionNEED HELP c# remoting need remotable class to use server's class's function Pin
neodeaths9-May-07 21:26
neodeaths9-May-07 21:26 
QuestionHow to restart the program after a function? Pin
Missy Glory9-May-07 21:12
Missy Glory9-May-07 21:12 
AnswerRe: How to restart the program after a function? Pin
Martin#9-May-07 21:20
Martin#9-May-07 21:20 
GeneralRe: How to restart the program after a function? Pin
Missy Glory9-May-07 21:33
Missy Glory9-May-07 21:33 
GeneralRe: How to restart the program after a function? Pin
Martin#9-May-07 21:38
Martin#9-May-07 21:38 
AnswerRe: How to restart the program after a function? Pin
Leyu10-May-07 2:15
Leyu10-May-07 2:15 
QuestionCalling Form Twice Pin
gvanto9-May-07 20:31
gvanto9-May-07 20:31 
Hey guys thanks for helping, I have the following:

* a main form, mainForm (the main application)
* i have a class, myClass
* i have an auxiliary form, auxForm which displays info about a certain process (method in myClass), say downloadData().

When I make a call to downloadData() the first time, auxForm is created and showed as follows:
<br />
class myClass{<br />
   AuxForm myAuxForm;<br />
<br />
// Load Data:<br />
   downloadData()<br />
   {<br />
    myAuxForm = new AuxForm (this); // launch new form<br />
    myAuxForm .Show();<br />
    doDataLoad();<br />
   }<br />
<br />
.<br />
.<br />
.<br />
}<br />


This works fine.

However, once the form has been closed, and I make another call to the above method,
I get an error:
<br />
System.ObjectDisposedException was unhandled<br />
  Message="Cannot access a disposed object.\r\nObject name: 'TextBox'."<br />
  Source="System.Windows.Forms"<br />
  ObjectName="TextBox"<br />


Given that its a textbox on the (closed) form causing the problem, it seems that the object myAuxForm, even though closed/disposed, is not reset to null.
(I have tried doing a if(myAuxForm == null) test before instantiating it again, but with no success).

If anyone has advice on how to get around this problem, it would be much appreciated!

For reference, here is the myAuxForm's code (actually called PriceUpdateForm):
<br />
partial class PriceUpdateForm : Form<br />
    {<br />
        // Thread delegates:<br />
        delegate void OutputDisplayCallback(string s, TextBox txtbxOutputTmp);<br />
        StockListManager m_slm;<br />
<br />
        public PriceUpdateForm(StockListManager slm)<br />
        {<br />
            InitializeComponent();<br />
            m_slm = slm;<br />
            m_slm.m_DisplayOutputEvt += new StockListManager.m_DisplayOutEH(DisplayOutputFromThread); // Attach delegate to StocklistManager<br />
        }<br />
<br />
        void DisplayOutputFromThread(string s)<br />
        {<br />
            DisplayOutput(s, txtbxOutput);<br />
        }<br />
<br />
<br />
        private void DisplayOutput(string s, TextBox txtbxOutputTmp)<br />
        {<br />
<br />
            if (txtbxOutputTmp.InvokeRequired) //Check if on different thread (it wont work otherwise!)<br />
            {<br />
                OutputDisplayCallback d = new OutputDisplayCallback(DisplayOutput);<br />
                this.Invoke(d, new object[] { s, txtbxOutputTmp });<br />
            }<br />
            else<br />
            {<br />
                txtbxOutputTmp.AppendText(s + "\n");<br />
                if ((s == "Price data update complete.") && (chbxCloseWhenDone.Checked))<br />
                    this.Hide();<br />
            }           <br />
        }<br />
        <br />
       <br />
    }<br />


In effect, it comes down to "How to make a call to the same form twice?" I think Smile | :)

Many thanks,
Gerry
C# newbie


Put A Smile On Your Face
http://www.thecrazywebsite.com

AnswerRe: Calling Form Twice Pin
sam#9-May-07 20:52
sam#9-May-07 20:52 
GeneralRe: Calling Form Twice Pin
gvanto9-May-07 21:24
gvanto9-May-07 21:24 
AnswerRe: Calling Form Twice Pin
Martin#9-May-07 21:37
Martin#9-May-07 21:37 
GeneralRe: Calling Form Twice Pin
gvanto10-May-07 1:23
gvanto10-May-07 1:23 
GeneralRe: Calling Form Twice Pin
Martin#10-May-07 1:26
Martin#10-May-07 1:26 
Questionanimated picture in form Pin
sujithkumarsl9-May-07 20:28
sujithkumarsl9-May-07 20:28 
AnswerRe: animated picture in form Pin
Martin#9-May-07 21:43
Martin#9-May-07 21:43 
GeneralRe: animated picture in form Pin
sujithkumarsl9-May-07 22:17
sujithkumarsl9-May-07 22:17 
QuestionPlzz Help in this program Pin
IrfanHaleem9-May-07 20:22
IrfanHaleem9-May-07 20:22 
AnswerRe: Plzz Help in this program Pin
sam#9-May-07 21:03
sam#9-May-07 21:03 
AnswerRe: Plzz Help in this program [modified] Pin
Guffa9-May-07 21:13
Guffa9-May-07 21:13 
Questioni want my application created in c# runs in screen server mode Pin
fgfdhghgfd9-May-07 20:08
fgfdhghgfd9-May-07 20:08 
AnswerRe: i want my application created in c# runs in screen server mode Pin
sam#9-May-07 20:55
sam#9-May-07 20:55 
AnswerRe: i want my application created in c# runs in screen server mode Pin
Martin#9-May-07 21:26
Martin#9-May-07 21:26 
QuestionRepresenting series Pin
Jack Hui9-May-07 20:07
Jack Hui9-May-07 20:07 
AnswerRe: Representing series Pin
Christian Graus9-May-07 20:20
protectorChristian Graus9-May-07 20:20 
GeneralRe: Representing series Pin
Jack Hui9-May-07 21:42
Jack Hui9-May-07 21:42 

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.