Skip to content

Instantly share code, notes, and snippets.

@Marceloromeugoncalves
Last active October 20, 2021 00:56
Show Gist options
  • Save Marceloromeugoncalves/41ea4c683fc473e0ab93433e91f7566d to your computer and use it in GitHub Desktop.
Save Marceloromeugoncalves/41ea4c683fc473e0ab93433e91f7566d to your computer and use it in GitHub Desktop.
Verificar se um form já está aberto.
//Abordagem mais legível.
public static bool FormIsOpen(string formName)
{
bool formIsOpen = Application.OpenForms.Cast<Form>().Any(form => form.Name == formName);
return formIsOpen;
}
//Utilizando Array Function.
public static bool FormIsOpen(string formName) => Application.OpenForms.Cast<Form>().Any(form => form.Name == formName);
if (Funcao.FormIsOpen(nameof(FormTeste)))
{
MessageBox.Show("O Form já está aberto.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment