Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. namespace WindowsFormsApplication1
  2. {
  3. public partial class FormCadastro : Form
  4. {
  5. public string modo = "Inserir";
  6.  
  7. // ...
  8.  
  9. private void formularioCadastro_Shown(object sender, EventArgs e)
  10. {
  11. // Altere "botaoAdicionar" para o nome do botão que você quer
  12. this.botaoAdicionar.Text = modo; // Inserir ou Alterar
  13. }
  14.  
  15. private void botaoAdicionar_Click(object sender, EventArgs e)
  16. {
  17. switch (modo)
  18. {
  19. case "Inserir":
  20. // Códigos para "inserir" aqui...
  21. break;
  22. case "Alterar":
  23. // Códigos para "alterar" aqui...
  24. break;
  25. default:
  26. break;
  27. }
  28. }
  29.  
  30. private void botaoInserir_Click(object sender, EventArgs e)
  31. {
  32. using (FormCadastro formCadastro = new FormCadastro())
  33. {
  34. formCadastro.modo = "Inserir";
  35. formCadastro.ShowDialog();
  36. }
  37. }
  38.  
  39. private void botaoAlterar_Click(object sender, EventArgs e)
  40. {
  41. using (FormCadastro formCadastro = new FormCadastro())
  42. {
  43. formCadastro.modo = "Alterar";
  44. formCadastro.ShowDialog();
  45. }
  46. }
  47.  
  48. var f = new MeuFormCadastro();
  49.  
  50. f.textBoxNome.Text = row.Nome;
  51. f.textBoxTelefone.Text = row.telefone;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement