471,330 Members | 1,490 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

using the show command

Hello!

When I have only one window how can the window form be displayed
when I don't have a show method. As in the example below with the Form class
FrmContainer

If I have an MDI child I must explicitly use the Show method for the MDI
child.

Can somebody explain that!
Is it possible to write some code which confirm that the show method is
called.
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
Application.Run(new FrmContainer());
}

public FrmContainer()
{
InitializeComponent();
}
//Tony
Jun 28 '08 #1
3 1226
On Sat, 28 Jun 2008 11:03:28 -0700, Tony Johansson
<jo*****************@telia.comwrote:
When I have only one window how can the window form be displayed
when I don't have a show method. As in the example below with the Form
class
FrmContainer [...]
I believe someone already answered this same question in a different
thread.

Pete
Jun 28 '08 #2
Hello!

The answer in another thread said the following.

"Application.Run calls Show
do this, redefine the Show method in your form and put a breakpoint
there, take a look in the call stack and you will see the call"
I redefined this Show in the following way
public new void Show()
{
...
}

I put a breakpoint on this redefined Show but there was no call to this
method

//Tony

"Peter Duniho" <Np*********@nnowslpianmk.comskrev i meddelandet
news:op***************@petes-computer.local...
On Sat, 28 Jun 2008 11:03:28 -0700, Tony Johansson
<jo*****************@telia.comwrote:
>When I have only one window how can the window form be displayed
when I don't have a show method. As in the example below with the Form
class
FrmContainer [...]

I believe someone already answered this same question in a different
thread.

Pete

Jun 29 '08 #3
On Sun, 29 Jun 2008 02:18:59 -0700, Tony Johansson
<jo*****************@telia.comwrote:
[...]
I redefined this Show in the following way
public new void Show()
{
...
}

I put a breakpoint on this redefined Show but there was no call to this
method
I admit, the term "redefine" is ambiguous. The person who wrote that to
you could have been more careful with his words. But what made you think
that hiding the base class Show() would accomplish what you wanted?

The short answer is that Show() is called implicitly when
Application.Run() is called. More generally, when you are writing new
versions of a virtual method, you practically always want to "override"
rather than "new".

Pete
Jun 30 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by seeni | last post: by
2 posts views Thread by Sharon | last post: by
1 post views Thread by Anonieko | last post: by
7 posts views Thread by Wiebe Tijsma | last post: by
reply views Thread by rosydwin | last post: by

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.