2

Looking for help on this project, I am new and might not know all terms so please bare with me.

Project contains multiple winforms panels. Start one is my dashboard then I have others that do specific functions/features. What I need to be able to do is call up the separate winforms from an outside bat file that comes from a third party software (I have no control over them).

So what I would like to do is this programname.exe runs the dashboard programname.exe -a runs a different winform with in my program. I am not sure what this is called to do this.

Any help would be great even if a place to go and look it up.

namespace Versi_Send_Email { public partial class DashBoard : Form { public DashBoard() { InitializeComponent(); } private void DashBoard_Load(object sender, EventArgs e) { INIFile inif = new INIFile(@"c:\test\mailsettings.ini"); sitetxtbox.Text = inif.Read("Properties", "site"); emailtotxtbox.Text = inif.Read("Properties", "personto"); cctotxtbox.Text = inif.Read("Properties", "ccto"); bcctextbox.Text = inif.Read("Properties", "bcto"); } 
1
  • 1
    Tip: your Main method gets the arguments from the command line Commented Jan 16, 2021 at 17:24

1 Answer 1

2

This could be a switch statement or a simple if-else statement. In WinForms application and in the main form loaded event, you can read the command line arguments like this

string[] args = Environment.GetCommandLineArgs(); foreach(string arg in args){ if (arg=="EmployeeForm") { EmployeeForm.ShowDialog() else if (arg=="Department") Department.ShowDialog() } //after all arguments are read, you can simply kill the application and main window will never appear Application.Current.Shutdown(); return; 
Sign up to request clarification or add additional context in comments.

1 Comment

OK I am trying this but getting errors with it. ` private void DashBoard_Load(object sender, EventArgs e) { string[] args = Environment.GetCommandLineArgs(); foreach (string arg in args) { if (arg == "DashBoard") { DashBoard.ShowDialog() else if (arg == "mail") mail.ShowDialog() } Application.Current.Shutdown(); return; }`

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.