You are on page 1of 4

using using using using using using using using

System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;

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

suma.Click += new EventHandler(this.GreetingBtn_click); metodo click this.Controls.Add(suma);

//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

void GreetingBtn_click(object sender, EventArgs e) { res.Text = num1t.Text + num2t.Text; //num2t.Text = num1t.Text; } } }

using using using using using using using using

System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;

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);

// permite adjuntar argumentos this.Controls.Add(suma);

this.Controls.Add(resta); this.Controls.Add(n1l); this.Controls.Add(n2l); this.Controls.Add(resl); this.Controls.Add(n1t); this.Controls.Add(n2t); this.Controls.Add(rest);

} 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

} void resta_click(object sender, EventArgs e) { //proceso rest.Text = Convert.ToString(Convert.ToUInt32(n1t.Text) + Convert.ToUInt32(n2t.Text)); } } }

You might also like