Last active
October 20, 2021 00:56
-
-
Save Marceloromeugoncalves/41ea4c683fc473e0ab93433e91f7566d to your computer and use it in GitHub Desktop.
Verificar se um form já está aberto.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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