Tema 08 - Aplicando Controles Listbox y Picturebox

10
UNIVERSIDAD PRIVADA SAN PEDRO ELECTIVO I Escuela de Informática & Sistemas WinForm Básico APLICANDO CONTROLES LISTBOX y PICTUREBOX En esta práctica se hace uso de las condiciones con la instrucción IF. CODIFICANDO using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace winArbole3 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btnSeleccionar_Click(object sender, EventArgs e) { int a, b, c, d,m; if (txtEscoger.Text == "") DOCENTE : Ing. Martin Saavedra Julca Pag.- 1

Transcript of Tema 08 - Aplicando Controles Listbox y Picturebox

Page 1: Tema 08 - Aplicando Controles Listbox y Picturebox

UNIVERSIDAD PRIVADA SAN PEDRO ELECTIVO I Escuela de Informática & Sistemas WinForm Básico

APLICANDO CONTROLES LISTBOX y PICTUREBOX

En esta práctica se hace uso de las condiciones con la instrucción IF.

CODIFICANDO

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

namespace winArbole3{ public partial class Form1 : Form { public Form1() { InitializeComponent(); }

private void btnSeleccionar_Click(object sender, EventArgs e) { int a, b, c, d,m;

if (txtEscoger.Text == "") return;

a = Convert.ToInt32(lblUno.Text); b = Convert.ToInt32(lblDos.Text); c = Convert.ToInt32(lblTres.Text); d = Convert.ToInt32(lblCuatro.Text);

DOCENTE : Ing. Martin Saavedra Julca Pag.- 1

Page 2: Tema 08 - Aplicando Controles Listbox y Picturebox

UNIVERSIDAD PRIVADA SAN PEDRO ELECTIVO I Escuela de Informática & Sistemas WinForm Básico

m = Convert.ToInt32(txtEscoger.Text);

if (m == a) { //AlfaRomeo// lblMensaje.Text = "Se compro un ALFA ROMERO"; } else if (m == b) { //Chevrolet// this.lblMensaje.Text = "Se compro un CHEVROLET"; } else if (m == c) { //MISTSUBISHI// this.lblMensaje.Text = "Se compro un MITSUBISHI-NATIVA"; } else if (m == d) { //HONDA// this.lblMensaje.Text = "SE compro una HONDA"; } else { //tecle otra vez// this.lblMensaje.Text = "tecle por favor un numero de la pantalla"; } } } // Fin de la Clase}

DOCENTE : Ing. Martin Saavedra Julca Pag.- 2

Page 3: Tema 08 - Aplicando Controles Listbox y Picturebox

UNIVERSIDAD PRIVADA SAN PEDRO ELECTIVO I Escuela de Informática & Sistemas WinForm Básico

PRACTICA 2

CODIFICACION

namespace Listas1{ public partial class frmCajaLista2 : Form {

avion a1 = new avion(0, 0, "n");

public frmCajaLista2() { InitializeComponent(); }

private void btnMostrar_Click(object sender, EventArgs e) { a1.Nombre = textBox1.Text; a1.Capacidad = Convert.ToInt32(textBox3.Text); a1.Velocidad = Convert.ToInt32(textBox2.Text);

listBox1.Items.Add(string.Format("{0,-20} {1,-10} {2,15}", "Modelo", "Capacidad", "Velocidad Max")); listBox1.Items.Add(string.Format("{0,-20} {1,-10} {2,15}", a1.Nombre, a1.Capacidad, a1.Velocidad));

}

private void frmCajaLista2_Load(object sender, EventArgs e) { this.lblTitulo.Text = "Introducir datos del avion"; }

}}

DOCENTE : Ing. Martin Saavedra Julca Pag.- 3

Page 4: Tema 08 - Aplicando Controles Listbox y Picturebox

UNIVERSIDAD PRIVADA SAN PEDRO ELECTIVO I Escuela de Informática & Sistemas WinForm Básico

using System;using System.Collections.Generic;using System.Text;

namespace winArbole3{ class avion { private string _nombre; private int _velocidad; private int _capacidad;

public avion(int c, int v) { Capacidad = c; Velocidad = v; }

public avion(int c, int v, string n) { Capacidad = c; Velocidad = v; Nombre = n; }

public avion() { }

public string Nombre { get { return _nombre; } set { _nombre = value; } }

public int Velocidad { get { return _velocidad; } set { if (value >= 0) { _velocidad = value; } else { _velocidad = 0; }

DOCENTE : Ing. Martin Saavedra Julca Pag.- 4

Page 5: Tema 08 - Aplicando Controles Listbox y Picturebox

UNIVERSIDAD PRIVADA SAN PEDRO ELECTIVO I Escuela de Informática & Sistemas WinForm Básico

} }

public int Capacidad { get { return _capacidad; } set { if (value >= 0) { _capacidad = value; } else { _capacidad = 0; } } }

} // Fin de la Clase Avion

}

DOCENTE : Ing. Martin Saavedra Julca Pag.- 5

Page 6: Tema 08 - Aplicando Controles Listbox y Picturebox

UNIVERSIDAD PRIVADA SAN PEDRO ELECTIVO I Escuela de Informática & Sistemas WinForm Básico

CONTROL RADIO BUTTON

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

namespace winRadioB{ public partial class frmControlRadio : Form { public frmControlRadio() { InitializeComponent(); }

private void Form1_Load(object sender, EventArgs e) { radioButton1.BackColor = Color.CadetBlue; radioButton2.BackColor = Color.CadetBlue; radioButton3.BackColor = Color.CadetBlue; }

private void radioButton1_CheckedChanged(object sender, EventArgs e) { //Valor del RadioButton1 se mostrara en la etiqueta, si lo selecciono label1.Text = "Seleccionado el Lenguaje " + radioButton1.Text; }

private void radioButton2_CheckedChanged(object sender, EventArgs e) { label1.Text = "Seleccionado el Lenguaje " + radioButton2.Text; }

private void radioButton3_CheckedChanged(object sender, EventArgs e) { label1.Text = "Seleccionado el Lenguaje " + radioButton3.Text; } }}

DOCENTE : Ing. Martin Saavedra Julca Pag.- 6

Page 7: Tema 08 - Aplicando Controles Listbox y Picturebox

UNIVERSIDAD PRIVADA SAN PEDRO ELECTIVO I Escuela de Informática & Sistemas WinForm Básico

CONTROL CHECBOX

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

namespace winRadioB{ public partial class frmControlCheck : Form { public frmControlCheck() { InitializeComponent(); }

private void checkBox1_CheckedChanged(object sender, EventArgs e) { }

private void button1_Click(object sender, EventArgs e) { string movies = "";

if (checkBox1.Checked) { movies = movies + checkBox1.Text + "\r\n"; }

DOCENTE : Ing. Martin Saavedra Julca Pag.- 7

Page 8: Tema 08 - Aplicando Controles Listbox y Picturebox

UNIVERSIDAD PRIVADA SAN PEDRO ELECTIVO I Escuela de Informática & Sistemas WinForm Básico

if (checkBox2.Checked) { movies = movies + checkBox2.Text + "\r\n"; }

if (checkBox3.Checked) { movies = movies + checkBox3.Text + "\r\n"; }

if (checkBox4.Checked) { movies = movies + checkBox4.Text + "\r\n"; }

if (checkBox5.Checked) { movies = movies + checkBox5.Text + "\r\n"; } MessageBox.Show(movies); }

private void button2_Click(object sender, EventArgs e) { string ChosenMovie = "";

if (radioButton1.Checked) { ChosenMovie = radioButton1.Text; } else if (radioButton2.Checked) { ChosenMovie = radioButton2.Text; } else if (radioButton3.Checked) { ChosenMovie = radioButton3.Text; } else if (radioButton4.Checked) { ChosenMovie = radioButton4.Text; } else if (radioButton5.Checked) { ChosenMovie = "Si pelicular Favorita es : " + radioButton5.Text; }

MessageBox.Show(ChosenMovie); } }}

DOCENTE : Ing. Martin Saavedra Julca Pag.- 8