Click here to Skip to main content
15,894,410 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I have a small Winform that shows a DatagridView with some data

Also I have a button that check if the String Format of each cell in one row is the same or not.

Now I need the ability to execute only that specific StringFormat_check Methode from a command line. I don't need to show the DatagridView, only to do the check and having a return like true or false or something like that.

I need to integrate that process in a specific Batch file.

to be honest I have no idea from where to start and what to do
any help would appreciated.

What I have tried:

............................................................
Posted
Updated 4-Apr-19 5:02am

What you can do is edit the Main method of your WinForms application and if you receive a certain command-line argument, say /checkOnly, then only call the StringFormat_check method:
C#
[STAThread]
static void Main(string[] args)
{
    if (args.Length > 0 && args[0] == "/checkOnly")
    {
        // do your stuff with StringFormat_check
    }
    else
    {
        // leave the default auto-generated code here, that probably looks like:
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }
}

And from your batch file, call your application like this:
YourWinFormsApp.exe /checkOnly <maybe other arguments here if needed>
 
Share this answer
 
v2
Comments
Nizar Belhiba 5-Apr-19 3:41am    
Thaaaank you.. and yet learned something new
 
Share this answer
 
Comments
Nizar Belhiba 5-Apr-19 3:41am    
Thaaaank you.. and yet learned something new

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900