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

x
?
Solved

c# windows app open another form on load

Posted on 2011-03-23
5
Medium Priority
?
752 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
[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
  • 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

715 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