Solved

c# windows app open another form on load

Posted on 2011-03-23
5
747 Views
Last Modified: 2012-05-11
Hi,

I am building a windows app in which I need to do this.

1) when the user clicks the icon to lauch the app I want it to load the form but also load another form "window" that displays certain information from the DB. Its like automatic reminders.

Question is how do i get another form to launch when openeing the main form.

Please help

Thanks,

R8VI
0
Comment
Question by:R8VI
  • 3
5 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35197477
You can simply have the Load event of the main form instantiate and show a secondary form:
// in load event of main form
SecondForm f = new SecondForm();
f.Show();

Open in new window

0
 
LVL 3

Expert Comment

by:MicMatic
ID: 35198854
If you want to make sure your new form to stay on top of the other form, you might want to use .ShowDialog()

The code is almost the same as mentioned above:

FormReminders frmReminders = new FormReminders();
frmReminders.ShowDialog();
0
 
LVL 3

Expert Comment

by:MicMatic
ID: 35198914
My bad, I intended to use preview...

An example of a basic class:

public partial class frmMainForm : Form {
  public frmIudexnet() {
    InitializeComponent();

    //You call your second form here (asuming you already created you form with the IDE)
    FormName frm = new FormName();
    frm.ShowDialog();
  }

Open in new window

0
 

Author Comment

by:R8VI
ID: 35202835
Hi,

Sorry I should have been a bit more specfic, I want the second form (reminders) to load and be displayed top left for example but first form to be displayed in the middle on the screen and focus on the first form

Thanks for the help so far

Thanks,

R8VI
0
 
LVL 3

Accepted Solution

by:
MicMatic earned 500 total points
ID: 35202967
In that case you should use this for your second form (after InitializeComponent()):

frmSecondForm.Show();

Open in new window


You can set the position using your Form-properties in your IDE: StartPosition: manual. After that you can set your location property to 0; 0

after calling the new form you can use:

this.TopMost = true;

Open in new window


that should keep your first form on top
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now