protected void LimpaDadosTela(FormPai form) { Type tipo = null; ComboBox combo = null; try { foreach (Control controle in form.Controls) { tipo = controle.GetType(); if (tipo.Equals(new TextBox().GetType()) == true || tipo.Equals(new MaskedTextBox().GetType()) == true || tipo.Equals(new TCC.Controle.MegaTextBox().GetType()) == true) { controle.Text = string.Empty; } else if (tipo.Equals(new ComboBox().GetType()) == true) { ((ComboBox)controle).SelectedIndex = 0; } else if (tipo.Equals(new DataGridView().GetType()) == true) { DataGridView grid = (DataGridView)controle; DataTable dt = (DataTable)grid.DataSource; if (dt != null) { dt.Rows.Clear(); grid.DataSource = dt; dt = null; } } else if (tipo.Equals(new GroupBox().GetType()) == true) { this.LimpaDadosTela((GroupBox)controle); } } } catch (Exception ex) { throw ex; } finally { tipo = null; if (combo != null) { combo.Dispose(); combo = null; } } }
protected void FechaTela(FormPai form) { frmInicial.listaTelasAbertas.Remove(form.Name); form.Close(); }