473,395 Members | 1,418 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

how do i pass control from one window to another?

Hi all,

I'm fairly new to c# and im trying to create a windows form application made up of 3 pages. The first, a login page, the second, a search page, and the third will be a page to fill in some fields to save the info to a database.

My problem is that i can not manage to transfer control from one page to another, that is, when the program launches, i can not get it so that it directs control to the login and then the use presses the login button, they are displayed the second page, which is the search page.

After having coded in java for a few years, i know that if this were a java application, all i would have to do is set the current thread of control to a frame and dispose of the previous frame, if you wish. My troubles in C# is that in using Web Forms, i can not seem to transfer control from one .cs file to another.

this is what i have tried:
By default, the windows forms creates a Form1.cs which is the entry point of the program. In the Form1() where it is supposed to call initiate(), i changed that to call my own login class:


Expand|Select|Wrap|Line Numbers
  1. public Form1()
  2.         {
  3.             InitializeComponent()
  4.         }
  5.  
i changed to this, expecting that my login page would pop up:

Expand|Select|Wrap|Line Numbers
  1. public Form1()
  2.         {
  3.  
  4.             new Login();
  5.         }
  6.  
when i do this, my login page does not come up, instead, a blank window comes up.

So, my question is the following:

how to do i create my application so that the entry point is through Form1, but then call Login() and my subsequent pages?

thanks, any guidance will be much appreciated.
Apr 20 '11 #1

✓ answered by adriancs

Expand|Select|Wrap|Line Numbers
  1. public Form1()
  2. {
  3.      InitializeComponent()
  4.      Login f = new Login();
  5.      f.ShowDialog();
  6. }

3 5541
adriancs
122 100+
Expand|Select|Wrap|Line Numbers
  1. public Form1()
  2. {
  3.      InitializeComponent()
  4.      Login f = new Login();
  5.      f.ShowDialog();
  6. }
Apr 30 '11 #2
Thank you very much! it worked like a charm!
May 2 '11 #3
bvrwoo
16
Also, if you want your Login to change when you are in another form and click for response, you can pass a delegate to the login to pick it up and change automatically. Make use of C# type function pointers (delegates) which I still prefer C/C++ for pointers any day of the week but .NET has a lot to offer to make your programming easier.
Aug 29 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Unregistered | last post by:
How do i pass info into another website which is not mine into a popu window Unregistered ----------------------------------------------------------------------- Posted via...
5
by: Georges Heinesch | last post by:
Hi. Is it possible to put a tab control inside another tab control. I tried it several times, but for some reason this doesn't seem to work. Can someone confirm this, or tell me what the trick...
5
by: Paul Mendez | last post by:
I am creating a form with a tab control containing 10 tabs. and what I want to do is on only on of the tabs, I want a sub section of tabs. So what it ends up being is one main tab control with...
7
by: Dave | last post by:
I have two forms, Form1 and Form2. From Form2, how do I reference the value in a control on Form1? Or perhaps a more specific question: Form1 contains a textbox with the value of 10. This form...
2
by: authorking | last post by:
How to access a control in another form and how to make a form become a MDI container.
3
by: qwerty | last post by:
I have two User controls in a page. Them ID-propertys are example UC1 and UC2. In code behind file they are declared: Public UC1 As UC1 Public UC1 As UC1 From the page I can call them with...
1
by: Greg Smith | last post by:
What is the syntax to reference a control on another page? I have a class module that I would like to code to change parameters on a series of controls on a web page. There are to many to pass by...
1
by: khalid sohail | last post by:
hi everybody i want to pass the window size parameter to <asp:hyperlink> attribute Navige URL Property. tell me how to pass the parameter to it.....actually i want to open the new window on the...
31
markryan57
by: markryan57 | last post by:
I have a VB program that acts as an interface for different functions - I am trying to run an Access program, where (for now) control is passed to Access from VB. When Access is done and the db is...
7
by: Boki | last post by:
Hi All, I can't pass data to another form: in form2: private void button1_Click(object sender, EventArgs e) { Form1 form_copy = new Form1();
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.