Advertisement
Guest User

Untitled

a guest
Jan 21st, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. public void AbrirFormulario(Type formType)
  2. {
  3. pnFormulários.Enabled = true;
  4. pnFormulários.Visible = true;
  5. this.SuspendLayout();
  6.  
  7. if (btVoltarInicio.Enabled == false)
  8. {
  9. try
  10. {
  11. for (int i = 0; i < lstFormulario.Count; i++)
  12. {
  13. lstFormulario[i].Close();
  14. lstFormulario[i].Dispose();
  15. lstFormulario[i] = null;
  16. }
  17.  
  18. lstFormulario.Clear();
  19.  
  20. Form form = (Form)Activator.CreateInstance(formType);
  21. form.WindowState = FormWindowState.Maximized;
  22. form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
  23. form.TopLevel = false;
  24.  
  25. pnFormulários.Controls.Add(form);
  26. form.Show();
  27.  
  28. lstFormulario.Add(form);
  29. }
  30. catch (Exception ex)
  31. {
  32. MessageBox.Show(ex.ToString());
  33. }
  34.  
  35. this.ResumeLayout(true);
  36. btVoltarInicio.Enabled = true;
  37. btVoltarInicio.Visible = true;
  38. }
  39. else
  40. {
  41.  
  42. }
  43. }
  44.  
  45. private void btCadCategorias_Click(object sender, EventArgs e)
  46. {
  47. AbrirFormulario(typeof(cadastro_categoria));
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement