473,949 Members | 22,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why does my new-ed form keep closing on me right after Show()-ing?

Hi all,

I'm certain this is stupid, but I'd like to know how to keep a form
open for, say, longer than 1ms. Here's the code I'm using to open my
form:

TestModelFileRe aderForm modelInfo = new TestModelFileRe aderForm();
modelInfo.txtMo delInfo.Text = elementInfo;
modelInfo.Show( );

MessageBox.Show ("Done walidating DTD", "Walidator" );
I exposed a textbox on the modelInfo form, and assign some text to it.

The reason for the MessageBox is that without it, the modelInfo form
will disappear as soon as its opened.

I've seen new-ed form code that *looks* just like mine, but (a) their
$%^$% windows stay open, and (b) they don't even need the form's Show()
method to be called - they just appear on the screen on their own.

How can I get this form to stay on the screen?

thanks in advance,

cdj

Aug 29 '06 #1
5 1535

sherifffruitfly wrote:
Hi all,

I'm certain this is stupid, but I'd like to know how to keep a form
open for, say, longer than 1ms. Here's the code I'm using to open my
form:

TestModelFileRe aderForm modelInfo = new TestModelFileRe aderForm();
modelInfo.txtMo delInfo.Text = elementInfo;
modelInfo.Show( );

MessageBox.Show ("Done walidating DTD", "Walidator" );
I exposed a textbox on the modelInfo form, and assign some text to it.

The reason for the MessageBox is that without it, the modelInfo form
will disappear as soon as its opened.

I've seen new-ed form code that *looks* just like mine, but (a) their
$%^$% windows stay open, and (b) they don't even need the form's Show()
method to be called - they just appear on the screen on their own.

How can I get this form to stay on the screen?
We would need to see the code for the TestModelFileRe aderForm class.

Aug 29 '06 #2

Bruce Wood wrote:
We would need to see the code for the TestModelFileRe aderForm class.
Oh. Ok. I think that code is just what VS came up with after I drew the
form in Designer, but here ya go:

using System;
using System.Drawing;
using System.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;

namespace TestMaker
{
/// <summary>
/// Summary description for TestModelFileRe aderForm.
/// </summary>
public class TestModelFileRe aderForm : System.Windows. Forms.Form
{
public System.Windows. Forms.TextBox txtModelInfo;
public System.Windows. Forms.Label lbl_ModelInfo;
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.Containe r components = null;

public TestModelFileRe aderForm()
{
//
// Required for Windows Form Designer support
//
InitializeCompo nent();

//
// TODO: Add any constructor code after InitializeCompo nent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}

And then there's the InitializeCompo nent() method, that's
autogenerated:

private void InitializeCompo nent()
{
this.lbl_ModelI nfo = new System.Windows. Forms.Label();
this.txtModelIn fo = new System.Windows. Forms.TextBox() ;
this.SuspendLay out();
//
// lbl_ModelInfo
//
this.lbl_ModelI nfo.Location = new System.Drawing. Point(24, 8);
this.lbl_ModelI nfo.Name = "lbl_ModelInfo" ;
this.lbl_ModelI nfo.Size = new System.Drawing. Size(464, 16);
this.lbl_ModelI nfo.TabIndex = 0;
this.lbl_ModelI nfo.Text = "Model Info for ";
//
// txtModelInfo
//
this.txtModelIn fo.Location = new System.Drawing. Point(24, 24);
this.txtModelIn fo.Multiline = true;
this.txtModelIn fo.Name = "txtModelIn fo";
this.txtModelIn fo.ScrollBars =
System.Windows. Forms.ScrollBar s.Vertical;
this.txtModelIn fo.Size = new System.Drawing. Size(464, 400);
this.txtModelIn fo.TabIndex = 1;
this.txtModelIn fo.Text = "";
//
// TestModelFileRe aderForm
//
this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
this.ClientSize = new System.Drawing. Size(512, 446);
this.Controls.A dd(this.txtMode lInfo);
this.Controls.A dd(this.lbl_Mod elInfo);
this.FormBorder Style =
System.Windows. Forms.FormBorde rStyle.FixedDia log;
this.Name = "TestModelFileR eaderForm";
this.StartPosit ion =
System.Windows. Forms.FormStart Position.Center Screen;
this.Text = "TestModelFileR eaderForm";
this.ResumeLayo ut(false);

}
#endregion
}

Aug 29 '06 #3
Actually, it sounds like your Application terminated.

TestModelFileRe aderForm modelInfo = new TestModelFileRe aderForm();
modelInfo.txtMo delInfo.Text = elementInfo;
Application.Run (modelInfo);

jliu

sherifffruitfly wrote:
Bruce Wood wrote:
We would need to see the code for the TestModelFileRe aderForm class.

Oh. Ok. I think that code is just what VS came up with after I drew the
form in Designer, but here ya go:

using System;
using System.Drawing;
using System.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;

namespace TestMaker
{
/// <summary>
/// Summary description for TestModelFileRe aderForm.
/// </summary>
public class TestModelFileRe aderForm : System.Windows. Forms.Form
{
public System.Windows. Forms.TextBox txtModelInfo;
public System.Windows. Forms.Label lbl_ModelInfo;
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.Containe r components = null;

public TestModelFileRe aderForm()
{
//
// Required for Windows Form Designer support
//
InitializeCompo nent();

//
// TODO: Add any constructor code after InitializeCompo nent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}

And then there's the InitializeCompo nent() method, that's
autogenerated:

private void InitializeCompo nent()
{
this.lbl_ModelI nfo = new System.Windows. Forms.Label();
this.txtModelIn fo = new System.Windows. Forms.TextBox() ;
this.SuspendLay out();
//
// lbl_ModelInfo
//
this.lbl_ModelI nfo.Location = new System.Drawing. Point(24, 8);
this.lbl_ModelI nfo.Name = "lbl_ModelInfo" ;
this.lbl_ModelI nfo.Size = new System.Drawing. Size(464, 16);
this.lbl_ModelI nfo.TabIndex = 0;
this.lbl_ModelI nfo.Text = "Model Info for ";
//
// txtModelInfo
//
this.txtModelIn fo.Location = new System.Drawing. Point(24, 24);
this.txtModelIn fo.Multiline = true;
this.txtModelIn fo.Name = "txtModelIn fo";
this.txtModelIn fo.ScrollBars =
System.Windows. Forms.ScrollBar s.Vertical;
this.txtModelIn fo.Size = new System.Drawing. Size(464, 400);
this.txtModelIn fo.TabIndex = 1;
this.txtModelIn fo.Text = "";
//
// TestModelFileRe aderForm
//
this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
this.ClientSize = new System.Drawing. Size(512, 446);
this.Controls.A dd(this.txtMode lInfo);
this.Controls.A dd(this.lbl_Mod elInfo);
this.FormBorder Style =
System.Windows. Forms.FormBorde rStyle.FixedDia log;
this.Name = "TestModelFileR eaderForm";
this.StartPosit ion =
System.Windows. Forms.FormStart Position.Center Screen;
this.Text = "TestModelFileR eaderForm";
this.ResumeLayo ut(false);

}
#endregion
}
Aug 30 '06 #4

John Liu wrote:
Actually, it sounds like your Application terminated.

TestModelFileRe aderForm modelInfo = new TestModelFileRe aderForm();
modelInfo.txtMo delInfo.Text = elementInfo;
Application.Run (modelInfo);
Close - the function that new-ed the form terminated - thus (I assume)
terminating everything declared within it.

I had the notion that new-ed objects - heap stuff - would persist past
the function they were new-ed in. My mistake. My fix was to call
myform.ShowDial og() rather than myform.Show() - that forces execution
to wait until the form is closed, which is good enough for me.

Aug 30 '06 #5
I suggest reading up the topics about application message loop,
Application class, Application.Run and Application.Qui t

jliu - johnliu.net

sherifffruitfly wrote:
John Liu wrote:
Actually, it sounds like your Application terminated.

TestModelFileRe aderForm modelInfo = new TestModelFileRe aderForm();
modelInfo.txtMo delInfo.Text = elementInfo;
Application.Run (modelInfo);

Close - the function that new-ed the form terminated - thus (I assume)
terminating everything declared within it.

I had the notion that new-ed objects - heap stuff - would persist past
the function they were new-ed in. My mistake. My fix was to call
myform.ShowDial og() rather than myform.Show() - that forces execution
to wait until the form is closed, which is good enough for me.
Aug 31 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
330
by: Supra | last post by:
in vc.net... private void comboBox1_DrawItem(object sender, DrawItemEventArgs e) { Bitmap bmp = new Bitmap(e.Bounds.Width,e.Bounds.Height,e.Graphics); Graphics g = Graphics.FromImage(bmp); g.FillRectangle(new SolidBrush(e.BackColor), new Rectangle(0,0,bmp.Width,bmp.Height)); g.DrawString(comboBox1.Items.ToString(),e.Font ,new SolidBrush(e.ForeColor), new Point(28,(bmp.Height-e.Font.Height)/2));
4
2174
by: Schraalhans Keukenmeester | last post by:
I have no clue why below code (found it somewhere and altered it a wee bit to my needs) will run without problem in both IE and Mozilla FireFox 1.0 but in the latter it takes up close to 100% cpu. It does check for type of browser, and indeed all works fine apart from that ridiculous amount of cpu taken. If you want to see if it does so in your firefox/xp too, it's embedded in my homepage (www.westerterp.com) Can anyone explain why...
4
8785
by: Astronomically Confused | last post by:
using System; using System.Collections; using System.IO; using System.Net; using System.Net.Sockets; using System.Threading; class HttpProcessor { private Socket s;
2
5171
by: Besta | last post by:
Hello all, I am having trouble creating a windows service with a timer. Everything seems to go ok but the elapsed event does not fire.Can anyone shed any light on this, may be something simple as I am new to this. Full code below : using System; using System.Collections; using System.ComponentModel;
18
1775
by: Daniel | last post by:
Hey guys I have an instance of an object say: List<Object> myList = new List<Object>(); Object myObject = new Object(); myObject.PositionVector = new Vector3(10,10,10); myList.Add(myObject);
52
3273
by: Julie | last post by:
I'm supporting an application at work. Below are some code segments that I can't understand how they work. First let me say, I would never code this standard. I'm just really creeped out that it works. Here's the setup. I have a function, called GetEmployeeCertifications, that is going to make a call to a SQL DB and return a result set. This module calls another function, called FillParameters, to determine if SQL parameters need to...
3
5728
by: Joachim Klassen | last post by:
Hi all, if I accidentally use a TAKEOVER command with BY FORCE clause while primary and standby are in peer state I'll end up with two primary's (at least with FP10 and Windows). Is this works as designed or a bug ? Manuals say that the standby will inform the primary about the takeover but will not wait for acknowledgement, so the primary knows about whats going on. In my eyes primary should either switch to standby or shutdown...
5
8116
by: mkaushik | last post by:
Hi everyone, Im just starting out with C++, and am curious to know how "delete <pointer>", knows about the number of memory locations to free. I read somewhere that delete frees up space assigned to <pointerby "new". Does "new" create a list of pointer names and the size of the memory array they point to? I also read that some compilers may store the number of consec mem locations a pointer points to, just before the first data...
14
3006
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why does K = parseInt('09') set K to 0? ----------------------------------------------------------------------- The parseInt function decides what base the number is by looking at the number. It assumes that any number beginning with '0x' or '0X' is hexadecimal, but it has a choice with a leading zero: the number can either be octal or decimal. Assuming...
6
14996
by: schnag | last post by:
import java.util.*; class Student { private String name; private int score; public Student() { name = ""; score = 0; }
0
10170
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11188
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11359
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10699
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9903
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8264
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7435
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6128
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4954
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.