944,189 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 3294
  • C# RSS
Mar 1st, 2007
0

What's wrong with this code?

Expand Post »
Is there anything wrong with this code?
C# Syntax (Toggle Plain Text)
  1.  
  2. namespace RotnetSudoku
  3. {
  4. public partial class splash : Form
  5. {
  6. public splash()
  7. {
  8. InitializeComponent();
  9. fclsStartScreen frmStartscreen = new fclsStartScreen();
  10. frmStartscreen.Show();
  11. this.Visible = false;
  12. }
  13. }
  14. }
Apart from the indentation?

When i run it ithe splash form doesn't close...Also, if i change
c# Syntax (Toggle Plain Text)
  1. this.Visible= false;
to
c# Syntax (Toggle Plain Text)
  1. this.close();
, i get this error:

System.ObjectDisposedException was unhandled
Message="Cannot access a disposed object.\r\nObject name: 'splash'."
Source="System.Windows.Forms"
ObjectName="splash"
StackTrace:
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Form.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at RotnetSudoku.Program.Main() in D:\Documents and Settings\T\My Documents\Visual Studio 2005\Projects\RotnetSudoku\RotnetSudoku\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
:!: :mad:
Last edited by scru; Mar 1st, 2007 at 7:07 pm.
Featured Poster
Reputation Points: 975
Solved Threads: 140
Posting Virtuoso
scru is offline Offline
1,624 posts
since Feb 2007
Mar 1st, 2007
0

Re: What's wrong with this code?

ok, i just realised that error description i posted isnt helpful at all...it told me that I can't call a destroyed object? something like that...
Featured Poster
Reputation Points: 975
Solved Threads: 140
Posting Virtuoso
scru is offline Offline
1,624 posts
since Feb 2007
Mar 6th, 2007
0

Re: What's wrong with this code?

To make it invisible use this code:

this.Hide();

BUT if you are hiding your main form, then you will have to use Application.Exit(); when you want to shut down the application. Otherwise it will still run and cause problems. If it's not the main form of your application (by that I mean Form1), then use this.Close(); to just simply get rid of the form.

Hope this helps
Last edited by RwCC; Mar 6th, 2007 at 8:28 am.
Reputation Points: 70
Solved Threads: 4
Junior Poster
RwCC is offline Offline
173 posts
since Jan 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: To Moderators
Next Thread in C# Forum Timeline: Open a file.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC