Link to home
Start Free TrialLog in
Avatar of R8VI
R8VI

asked on

c# windows app open another form on load

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
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

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

Avatar of Member_2_6211924
Member_2_6211924

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();
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

Avatar of R8VI

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Member_2_6211924
Member_2_6211924

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial