Professional Documents
Culture Documents
Using Using Using Using Using Using Using Using Namespace Public Partial Class
Using Using Using Using Using Using Using Using Namespace Public Partial Class
namespace prime { public partial class Form1 : Form { // declaracion e v globales Button suma; TextBox num1t, num2t, res; Label num1l, num2l, resl;
public Form1() { InitializeComponent(); // metodo constructor suma = new Button(); num1t = new TextBox(); num1l = new Label(); num2t = new TextBox(); num2l = new Label(); res = new TextBox(); resl = new Label(); num1t.Left = 100; num1t.Top = 40; num2t.Left = 200; num2t.Top = 40; res.Left = 300; res.Top = 40; num1l.Left = 100; num2l.Left = 200; resl.Left = 300; suma.Text = "suma"; num1l.Text = "num1"; num2l.Text = "num2"; resl.Text = "resul"; // etiquetas // desplazamiento
//llamado
this.Controls.Add(num1t); this.Controls.Add(num1l); this.Controls.Add(num2t); this.Controls.Add(num2l); this.Controls.Add(res); this.Controls.Add(resl); } private void Form1_Load(object sender, EventArgs e) evento formulario { // se ejecuto 1er
namespace multieventos { public partial class Form1 : Form { Button suma, resta; Label n1l, n2l, resl; TextBox n1t, n2t, rest; public Form1() { InitializeComponent(); suma=new Button(); resta =new Button(); n1l = new Label(); n2l = new Label(); resl = new Label(); n1t = new TextBox(); n2t = new TextBox(); rest = new TextBox(); // posicionar los label n1l.Left = 100; n2l.Left = 200; resl.Left = 300; // posicionar los text n1t.Left = 100; n1t.Top = 40; n2t.Left = 200; n2t.Top = 40; rest.Left = 300; rest.Top = 40; resta.Top = 40; resta.Text = "-"; suma.Text = "+"; n1l.Text = "n1"; n2l.Text = "n2"; resl.Text = "resultado"; suma.Click += new EventHandler(this.suma_click); resta.Click += new EventHandler(this.resta_click);
} private void Form1_Load(object sender, EventArgs e) evento formulario { //proceso. } void suma_click(object sender, EventArgs e) { //proceso rest.Text = Convert.ToString(Convert.ToUInt32(n1t.Text) + Convert.ToUInt32(n2t.Text)); // se ejecuto 1er