-5

How do I kill a process, given the title of a form hosted in that process?

how to kill the program runs as system retired. While I only had the title of it?

1 Answers1

3

I believe you are trying to close your form. If so then you can use Application.OpenForms property and get the form based on the title like:

var form = Application.OpenForms
                      .Cast<Form>()
                      .FirstOrDefault(r=> r.Text == "YourTitle");
if(form != null)
    form.Close();

You should consider that there could be multiple forms for same title.

Habib
  • 219,104
  • 29
  • 407
  • 436