nevermind, problem has been solved.
Hi.
I have registered a file association with my program, and when the file is clicked I want it to open with my application by passing a command line argument. I have already done this and in Program.cs I have added:
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Main x = new Main();
x.Launch(args[0]);
Application.Run(x); // I also tried Application.Run(new Main());
}
Launch is a function in my main form, I want to pass the arguments there. From there, I want to change the text of the form (this.Text = args for example), but it doesn't work.
Can someone please help me pass the argument to the main form so I can use it there on my main form?
Loading
Amit ChoudharyPosted Nov 3, 2010, 6:04 AM
overload the form() contructor and pass the argument in the constructor after calling the initializeComponent() set the text to the value that you passed into the form constructor.
Implementation:
Form(string arg)
{
InitializeComponent();
textbox1.text=arg;
}
Create new instance of form in main:
Form f=new Form(arg[0]);
Please mark "Do you like this post?" if it helps you