Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

On Button Click Load Windows Form

Posted on 2008-09-29
2
Medium Priority
?
1,679 Views
Last Modified: 2013-12-17
Its been a while sense I've used Visual Studio so bare with me.  What is the line of code that will load a new form when I click a button and run a check.  I would expect it to be Load.Form1.cs or something along those lines.  Thank you!
0
Comment
Question by:ReganJ03
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Expert Comment

by:Jai S
ID: 22596267

yourFormName frmObject = new yourFormName();
frmObject.ShowDialog(); // or frmObject.Show();
0
 
LVL 15

Accepted Solution

by:
angus_young_acdc earned 150 total points
ID: 22596573
Here is what it would look like in your button.

The last two (this.hide and this.close) are optional and don't need to be done unless you want to, and you should pick one or the other (not use both as in the example below).  Also if you use Close on your main form it will stop your application completely, so all other forms will close.
        private void button1_Click(object sender, EventArgs e)
        {
            Form2 openForm = new Form2();
            openForm.Show();              // Opens the other form
           
            this.Hide();                // Hide the current form 
            this.Close();               // Closes the current form
        }

Open in new window

0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

660 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