Solved

How to show a form from a button in C# 2012?

Posted on 2014-12-23
4
82 Views
Last Modified: 2015-01-07
The following code should work, but instead I get an error for the line:

frmInvoice.Show;  
Error: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement.

What am I doing wrong?

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

Open in new window

0
Comment
Question by:Sheryl Landis
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
Sammy earned 500 total points
ID: 40515405
Show is a method and should be called as such
Show();
private void button1_Click(object sender, EventArgs e)
        {
            FormInvoice frmInvoice = new FormInvoice();
            frmInvoice.Show();       
        }

Open in new window

More about the show method
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.show%28v=vs.110%29.aspx
0
 

Author Comment

by:Sheryl Landis
ID: 40515449
That's it, thank you!
0
 
LVL 27

Expert Comment

by:Sammy
ID: 40515450
You welcome
0
 
LVL 33

Expert Comment

by:it_saige
ID: 40515477
*No Points*

You also have an additional method called ShowDialog.  The difference is that Show does not block your code and allows for the user to move between the parent/child windows at will.  Show is perfect for scenarios where the parent/child are not codependent.

In cases where the parent is launching a child window because the child is responsible for additional logic and/or information that will be displayed later on the parent, that is when ShowDialog is beneficial.

Show vs. ShowDialog

-saige-
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Web Form VB.Net  import CSV 4 39
Question! 4 36
Where did System.Data.Objects go? 2 28
Winform Module - What is the ASP.Net equiv 2 23
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question