[Solved] Get a list of all excel processes started by winform application

Okay I have found the answer myself. I am sharing it just in case someone needs it. int myappid = Process.GetCurrentProcess().Id; Process[] processes = Process.GetProcessesByName(“EXCEL”); foreach (Process prs in processes) { var query = string.Format(“SELECT ParentProcessId FROM Win32_Process WHERE ProcessId = {0}”, prs.Id); var search = new ManagementObjectSearcher(“root\\CIMV2”, query); var results = search.Get().GetEnumerator(); results.MoveNext(); var … Read more

[Solved] how to add value from one combo box to another combo box

If I have understand you correctly, this code will help you private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { //If you need, clear second combo box from old values before you copy //comboBox2.Items.Clear(); foreach (var item in comboBox1.Items) { if (item != comboBox1.SelectedItem) { comboBox2.Items.Add(item); //If you need to remove item that were copied to second … Read more

[Solved] How to download images from a website that are running in a loop?

I assume you mean that you get a URL of the form: “http://www.niederschlagsradar.de/images.aspx? jaar=-6&type=europa.precip&datum=201309171500&cultuur=en-GB&continent=europa” And you want to extract that date and time bit so you can compare it against a list of images that you already have. So in the above, you want to get the 201309171500. You can do that with a regular … Read more

[Solved] How to open one window and close another on button click [closed]

Let’s say you have a main form. Call it frmMain. In frmMain before IntializeComponent frmLogin loginForm = new frmLogin(); //Set the dialog result on login form depending on ok and cancel button //close the application if user wants to cancel if(loginForm.DialogResult == DialogResult.Cancel) this.Close(); //else you can continue to call your frmMain initializeComponent method solved … Read more

[Solved] How can I get a Boolean from form 2 to form1?

1- Create a new property In Form2 like this public partial class Form2: Form { public static bool BolleanProperty { get; set; } // … } 2- in the static constructor set property BolleanProperty = true public partial class Form2: Form { public static bool BolleanProperty { get; set; } static Form2() { BolleanProperty = … Read more

[Solved] How to remember a variable at each application startup? [duplicate]

You can use application settings behavior provided by the Framework and Visual Studio designer using the settings.settings file in the properties section of the project in the solution explorer. You create a parameter of string type for example MyStringParameter and you read and write access it like that: Settings are automatically loaded at the program … Read more

[Solved] Issue with drag and drop

You may use a BackgroundWorker to do the operation that you need in different thread like the following : BackgroundWorker bgw; public Form1() { InitializeComponent(); bgw = new BackgroundWorker(); bgw.DoWork += bgw_DoWork; } private void Form1_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] s = (string[])e.Data.GetData(DataFormats.FileDrop, false); bgw.RunWorkerAsync(s); } } Also for your issue … Read more

[Solved] How to call a form when there are 3 forms in a project and data Transfer between the forms in C#?

Can you explain why you don’t want to touch your Program.cs file? This is exactly where you change the start-up form. Change the: Application.Run(new Form1()); to: Application.Run(new Form4()); Secondly, you can set the filters on Open- and SaveFileDialog using the Filter property. Set it to a value like this: XML Files|*.xml Or for text: Text … Read more

[Solved] System.ArgumentOutOfRangeException Toolstrip menu

Although this question is downvoted for good reasons, it’s the only hit I got while googling for “xLayoutRow ArgumentOutOfRangeException”, so I’ll still share my experiences here. I encountered an exception with the top part of the stack trace in this post: System.ArgumentOutOfRangeException – Index was out of range. Must be non-negative and less than the … Read more