APLICACION2 turorial

28
2011 MECATRÓNICA, ÁREA AUTOMATIZACIÓN TUTORIAL DE LA APLICACIÓN 2 LENGUAJE DE PROGRAMACIÓN ISC. Luz María Feregrino Martínez

Transcript of APLICACION2 turorial

Page 1: APLICACION2 turorial

2011

MECATRÓNICA, ÁREA AUTOMATIZACIÓN

TUTORIAL DE LA APLICACIÓN 2 LENGUAJE DE PROGRAMACIÓN

ISC. Luz María Feregrino Martínez

Page 2: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

2 Tutorial de la Aplicación 2

Lenguaje de Programación

Objetivos:

Luego de completar esta Aplicación, el alumno será capaz de:

Identificar los elementos del entorno integrado de desarrollo de Microsoft Visual C#

Añadir controles a formularios.

Establecer las propiedades de los controles.

Trabajar con procedimientos de eventos.

Crear una aplicación con menús.

Esta aplicación permite integrar varios componentes del lenguaje Visual C#, como por ejemplo

Label, TextBox, GoupBox, ListBox, ComboBox, Button, MenuStrip, Masked TextBox, CheckBox,

RadioButton, HScrollBar, VScrollBar, TrackBar, DomainUpDowny NumericUpDown.

Pasos a seguir:

Sobre el Form 1 realizar lo siguiente:

Page 3: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

3 Tutorial de la Aplicación 2

Lenguaje de Programación

Propiedades del Form 1

Name frmPrincipal

Text Principal

Insetar 2 Label, 1 TextBox, 1 MaskedTextBox, 2 Button

Cambiar propiedades de los componentes insertados en el frmPrincipal

Page 4: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

4 Tutorial de la Aplicación 2

Lenguaje de Programación

Propiedades de label1

Text Ususario

Propiedades del label2

Text Password

Propiedades del TextBox1

Name txtUsuario

Propiedades del MaskedTextBox

Name mtxPass

Password Key *

Propiedades del button1

Name btnAceptar

Text Aceptar

Propiedades del button2

Name btnSalir

Text Salir

Codificación de btnSalir (Botón de Salir)

private void btnSalir_Click(object sender, EventArgs e) { Application.Exit(); }

Agregar nuevo elemento Agregar una clase

Page 5: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

5 Tutorial de la Aplicación 2

Lenguaje de Programación

Seleccionar Clase

Nombre de la clase Validaciones

El código de la clase Validaciones debe quedar de la siguiente manera:

Page 6: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

6 Tutorial de la Aplicación 2

Lenguaje de Programación

Codificación de la clase Validaciones

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Aplicacion2 { class Validaciones { //Método que permite validar si una cadena es de tipo double public bool isDouble(String cadena) { bool ban = false; for (int i = 0; i < cadena.Length; i++) { char c = cadena[i]; if (c >= '0' && c <= '9') { continue; } else { if ((c == '.') && (i != 0 && i < (cadena.Length - 1)) && (cadena[i - 1] != '.')) { ban = true; } else { return false; } } } return ban; } //Método que permite validar si una cadena es de tipo int public bool isInt(String cadena) { bool ban = false; for (int i = 0; i < cadena.Length; i++) { char c = cadena[i]; if (c >= '0' && c <= '9') { ban = true; continue; } else { return false; } } return ban; } } }

Page 7: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

7 Tutorial de la Aplicación 2

Lenguaje de Programación

Insertar 6 Form, en total deben ser 7 con el primero

NOTA: Recordar que para agregar código a un button (botón), basta con hacer doble clic sobre él.

En el Form 2 realizar lo siguiente:

Propiedades del Form 2

Name frmMenu

Text Menu

Insertar 1 MenuStrip y 1 Button

Page 8: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

8 Tutorial de la Aplicación 2

Lenguaje de Programación

Propiedades del MenuScrip

Name mstMenu

Propiedades del Button1

Name btnRegresar

Text Regresar

Codificación de btnRegresar (Botón de Regresar)

private void btnRegresar_Click(object sender, EventArgs e) { frmPrincipal fp = new frmPrincipal(); fp.Show(); this.Visible = true; }

Page 9: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

9 Tutorial de la Aplicación 2

Lenguaje de Programación

Editar mstMenu, Dar clic en la parte azul, donde dice escriba aquí, teclear Controles y generar el siguiente

Menu

Entre cada opción insertar un separador, ejemplo seleccionar el texto de CheckBox y RadioButton, dar clic derecho

seleccionar Insertar y dar clic en Separador.

CODIFICACIÓN DEL BOTON ACEPTAR DEL frmPrincipal

Codificación de btnAceptar(Botón de Aceptar)

public String U = "hola", P = "123"; //Declaración de variables private void btnAceptar_Click(object sender, EventArgs e) { if (txtUsuario.Text.Trim() != "") { if (mtxPass.Text.Trim() != "") { if (txtUsuario.Text.Equals(U)) { if (mtxPass.Text.Equals(P)) { frmMenu fm = new frmMenu(); fm.Show(); this.Visible = false; } else { MessageBox.Show("Password Incorrecto");

Page 10: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

10 Tutorial de la Aplicación 2

Lenguaje de Programación

mtxPass.Focus(); } } else { MessageBox.Show("Usuario Incorrecto"); txtUsuario.Focus(); } } else { MessageBox.Show("Teclee Password"); mtxPass.Focus(); } } else { MessageBox.Show("Teclee Usuario"); txtUsuario.Focus(); } }

Cambiar las propiedades de los 5 Form restantes

Propiedades del Form3

Name btnListas

Text Listas

Propiedades del Form4

Name btnOpciones

Text Opciones

Propiedades del Form5

Name btnBarras

Text Barras de Desplazamiento

Propiedades del Form6

Name btnListasNum

Text Otras Listas

Propiedades del Form7

Name btnProyecto

Text Proyecto Integrador

Codificación de las opciones del menú:

Codificación de la opción ComboBox y ListBox

private void comboBoxYListBoxToolStripMenuItem_Click(object sender, EventArgs e) { frmListas fl = new frmListas(); fl.Show(); this.Visible = false; }

Page 11: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

11 Tutorial de la Aplicación 2

Lenguaje de Programación

Codificación de la opción CheckBox y Radiobutton

private void checkBoxToolStripMenuItem_Click(object sender, EventArgs e) { frmOpciones fo = new frmOpciones(); fo.Show(); this.Visible = false; }

Codificación de la opción HScrollBar,VScrollBar, y StacBar

private void hScrollBarVScrollBaryStacBarToolStripMenuItem_Click(object sender, EventArgs e) { frmBarras fb = new frmBarras(); fb.Show(); this.Visible = false; }

Codificación de la opción DomainUpDown y NumericUpDown

private void domainUpDownYNumericUpDownToolStripMenuItem_Click(object sender, EventArgs e) { frmListasNum fln = new frmListasNum(); fln.Show(); this.Visible = false; }

Codificación de la opción VariosProyecto Integrador

private void proyectoIntegradorToolStripMenuItem_Click(object sender, EventArgs e) { frmProyecto fproy = new frmProyecto(); fproy.Show(); this.Visible = false; }

En el Form3 llamado frmListas insertar los siguientes componentes: 6 groupBox, 3 label, 9 button, 5

textBox, 2 comboBox y 2 listBox.

Generar la siguiente estructura:

Page 12: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

12 Tutorial de la Aplicación 2

Lenguaje de Programación

Cambiar las propiedades de los componentes del frmListas

Propiedades de groupBox1

Text ComboBox

Propiedades de groupBox2

Text ListBox

Propiedades de groupBox5

Text Agregar en

Propiedades de groupBox3

Text Números en ComboBox

Propiedades de groupBox4

Text Números en ListBox

Propiedades de groupBox6

Text Dato

Propiedades de label1

Text Volts

Propiedades del label2

Text Promedio

Propiedades del label3

Text Promedio

Propiedades del TextBox1

Name txtVolts

Propiedades del TextBox2

Name txtPromC

Page 13: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

13 Tutorial de la Aplicación 2

Lenguaje de Programación

Propiedades del TextBox3

Name txtPromL

Propiedades del TextBox4

Name txtCombo

Multiline True

Propiedades del TextBox5

Name txtLista

Multiline True

Propiedades del button1

Name btnRegresar

Text Regresar

Propiedades del button2

Name btnCombo

Text En ComboBox

Propiedades del button3

Name btnListBox

Text En ListBox

Propiedades del button4

Name btnSeleccionarC

Text Seleccionar

Propiedades del button5

Name btnLimpiarC

Text Limpiar

Propiedades del button6

Name btnDeseleccionarC

Text Deseleccionar

Propiedades del button7

Name btnSeleccionarL

Text Seleccionar

Propiedades del button8

Name btnLimpiarL

Text Limpiar

Propiedades del button9

Name btnDeseleccionarL

Text Deseleccionar

Propiedades del comboBox1

Name cboVolts

Text Volts

Propiedades del listBox1

Name lsbVolts

Propiedades del comboBox2

Name cboNum

Text Número

Items Colección

Propiedades del listBox2

Name lsbNum

Items Colección

Page 14: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

14 Tutorial de la Aplicación 2

Lenguaje de Programación

Propiedad Items del cboNum

Propiedad Items del lsbNum

Page 15: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

15 Tutorial de la Aplicación 2

Lenguaje de Programación

Inicializar el cboVolts y el lsbVolts dentro del contructor

public frmlistas() { InitializeComponent(); lsbVolts.Items.Add("Volts"); //inicializar el lsbVolts lsbNum.Items.Add("Número"); //inicializar el lsbNum } Declarar las siguientes variables de campo o atributo debajo del constructor

public int i, j; public double V, P, sumcbo = 0, sumlsb = 0; int indC=0, indL=0; String itC = "", itL=""; Validaciones valida = new Validaciones(); // Crear variable de instancia de la clase Validaciones

Codificación de btnCombo (Botón de En ComboBox)

private void btnCombo_Click(object sender, EventArgs e) { if (txtVolts.Text.Trim() != "") { if (valida.isDouble(txtVolts.Text) || valida.isInt(txtVolts.Text)) { V = Convert.ToDouble(txtVolts.Text); cboVolts.Items.Add(V); sumcbo = sumcbo + V; i++; P = sumcbo / i; txtVolts.Clear(); txtPromC.Text = Convert.ToString(P); } else { MessageBox.Show("Teclee Voltaje"); txtVolts.Clear(); txtVolts.Focus(); } } else { MessageBox.Show("No ha tecleado Voltaje"); txtVolts.Focus(); } } } }

Page 16: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

16 Tutorial de la Aplicación 2

Lenguaje de Programación

Codificación de btnListBox (Botón de En ListBox)

private void btnListBox_Click(object sender, EventArgs e) { if (txtVolts.Text.Trim() != "") { if (valida.isDouble(txtVolts.Text) || valida.isInt(txtVolts.Text)) { V = Convert.ToDouble(txtVolts.Text); lsbVolts.Items.Add(V); sumlsb = sumlsb + V; j++; P = sumlsb / j; txtVolts.Clear(); txtPromL.Text = Convert.ToString(P); } else { MessageBox.Show("Teclee Voltaje"); txtVolts.Clear(); txtVolts.Focus(); } } else { MessageBox.Show("No ha tecleado Voltaje"); txtVolts.Focus(); } }

Codificación de cboNum

private void cboNum_SelectedIndexChanged(object sender, EventArgs e) { try { indC = cboNum.SelectedIndex; itC = cboNum.SelectedItem.ToString(); } catch { } }

Codificación de btnSeleccionarC (Botón de Seleccionar) del grupo de ComboBox

private void btnSeleccionarC_Click(object sender, EventArgs e) { txtCombo.Text = "El número seleccionado es: " + indC + "y su posicion es: " + itC; }

Page 17: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

17 Tutorial de la Aplicación 2

Lenguaje de Programación

Codificación de btnDeseleccionarC (Botón de Deseleccionar) del grupo de ComboBox

private void btnDeseleccionarC_Click(object sender, EventArgs e) { cboNum.SelectedIndex = -1; txtCombo.Clear(); cboNum.Text = "Número"; indC = 1; itC = ""; }

Codificación de btnLimpiarC (Botón de Limpiar) del grupo de ComboBox

private void btnLimpiarC_Click(object sender, EventArgs e) { cboNum.Text="Número"; cboNum.Items.Clear(); txtCombo.Clear(); }

Codificación de lsbNum

private void lsbNum_SelectedIndexChanged(object sender, EventArgs e) { try { indL = lsbNum.SelectedIndex; itL = lsbNum.SelectedItem.ToString(); } catch { } }

Codificación de btnSeleccionarL (Botón de Seleccionar) del grupo de ListBox

private void btnSeleccionarL_Click(object sender, EventArgs e) { txtLista.Text = "El número seleccionado es: " + indL + "y su posicion es: " + itL; }

Codificación de btnDeseleccionarL (Botón de Deseleccionar) del grupo de ListBox

private void btnDeseleccionarL_Click(object sender, EventArgs e) { lsbNum.SelectedIndex = 0; txtLista.Clear(); indL = 1; itL = ""; }

Page 18: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

18 Tutorial de la Aplicación 2

Lenguaje de Programación

Codificación de btnLimpiarL(Botón de Limpiar) del grupo de ComboBox

private void btnLimpiarL_Click(object sender, EventArgs e) { lsbNum.Items.Clear(); lsbNum.Items.Add("Número"); txtLista.Clear(); }

Codificación de btnRegresar

private void btnRegresar_Click(object sender, EventArgs e) { frmMenu m=new frmMenu(); m.Show(); this.Visible = false; }

En el Form4 llamado frmOpciones insertar los siguientes componentes: 2 groupBox, 2 label, 2 button,

1 textBox, 5 checkBox, 5 radioButton , 1 pictureBox y sobre el pictureBox insertar 1 imageList.

Generar la siguiente estructura:

Page 19: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

19 Tutorial de la Aplicación 2

Lenguaje de Programación

Cambiar las propiedades de los componentes del frmOpciones

Propiedades de groupBox1

Text COLORES

Name grbColores

Propiedades de groupBox2

Text COMPONENTES

Name grbComponentes

Propiedades de label1

Text COLORES

Name lblColores

Propiedades del label2

Text IMAGEN

Propiedades del TextBox1

Name txtColores

Text COLORES

Propiedades del button1

Name btnRegresar

Text Regresar

Propiedades del button2

Name btnDesactivar

Text Desactivar

Propiedades del checkBox1

Name chkRojo

Text Rojo

Propiedades del checkBox2

Name chkVerde

Text Verde

Propiedades del checkBox3

Name chkAzul

Text Azul

Propiedades del checkBox4

Name chkRosa

Text Rosa

Propiedades del checkBox5

Name chkAmarillo

Text Amarillo

Propiedades del radioButton1

Name rdbLabel

Text Label

Propiedades del radioButton2

Name rdbColores

Text GroupBoxColores

Propiedades del radioButton3

Name rdbComponentes

Text GroupBoxComponentes

Propiedades del radioButton4

Name rdbTextBox

Text TextBox

Propiedades del radioButton5

Page 20: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

20 Tutorial de la Aplicación 2

Lenguaje de Programación

Agregar imágenes a imageList1

Name rdbPictureBox

Text PictureBox

Propiedades del pictureBox

Name pcbPicture

Dar click

en la fecha

Page 21: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

21 Tutorial de la Aplicación 2

Lenguaje de Programación

Cambiar el tamaño de las imágenes y elegir la profundidad de las imágenes.

Dar click en Elegir las imágenes que se desea contenga el componente imageList, tomando en cuenta

que las almacenara en un arreglo, iniciando en la posición 0.

Dar click en el botón Agregar, para que muestre el explorador y poder elegir las imágenes que se

agregaran a imageList

Después de seleccionar las imágenes dar click en Abrir, quedando de la siguiente manera:

Dar click en el botón aceptar.

CODIFICACIÓN DEL FORMULARIO DE OPCIONES (frmOpciones)

Page 22: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

22 Tutorial de la Aplicación 2

Lenguaje de Programación

Declarar variables de campo o de atributo, debajo del constructor

public int i = 0, j = 0; // la variable i ayudara identificar que checkBox esta seleccionado // mientras que la j ayudara a identificar que radioButton esta seleccionado.

Realizar los siguientes métodos después de la declaración de las varibles i y j.

//Método que permite desactivar los checkBox, cuando uno de ellos esta seleccionado public void Desactivar_CheckBox() { chkAzul.AutoCheck = false; chkAmarillo.AutoCheck = false; chkRosa.AutoCheck = false; chkRojo.AutoCheck = false; chkVerde.AutoCheck = false; } //Método que permite activar los checkBox, para uno de ellos pueda ser seleccionado public void Activar_CheckBox() { chkAzul.AutoCheck = true; chkAmarillo.AutoCheck = true; chkRosa.AutoCheck = true; chkRojo.AutoCheck = true; chkVerde.AutoCheck = true; } //Método que permite deseleccionar el checkBox que se encuentre seleccionado public void Desactivar_CheckBox1() { chkAzul.Checked = false; chkAmarillo.Checked = false; chkRosa.Checked = false; chkRojo.Checked = false; chkVerde.Checked = false; } //Método que permite deseleccionar el radioButton que se encuentre seleccionado public void Desactivar_RadioButton() { rdbBotones.Checked = false; rdbColores.Checked = false; rdbComponentes.Checked = false; rdbEtiqueta.Checked = false; rdbPictureBox.Checked = false; }

Page 23: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

23 Tutorial de la Aplicación 2

Lenguaje de Programación

//Método que permite hacer ciertas acciones si cierto checkBox y radioButton están seleccionados public void opciones() { if (i == 1 && j == 1) { lblColores.ForeColor = Color.Red; } else if (i == 2 && j == 1) { lblColores.ForeColor = Color.Green; } else if (i == 3 && j == 1) { lblColores.ForeColor = Color.Blue; } else if (i == 4 && j == 1) { lblColores.ForeColor = Color.Pink; } else if (i == 5 && j == 1) { lblColores.ForeColor = Color.Yellow; } else if (i == 1 && j == 2) { grbColores.BackColor = Color.Red; } else if (i == 2 && j == 2) { grbColores.BackColor = Color.Green; } else if (i == 3 && j == 2) { grbColores.BackColor = Color.Blue; } else if (i == 4 && j == 2) { grbColores.BackColor = Color.Pink; } else if (i == 5 && j == 2) { grbColores.BackColor = Color.Yellow;

Page 24: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

24 Tutorial de la Aplicación 2

Lenguaje de Programación

} else if (i == 1 && j == 3) { grbComponentes.BackColor = Color.Red; } else if (i == 2 && j == 3) { grbComponentes.BackColor = Color.Green; } else if (i == 3 && j == 3) { grbComponentes.BackColor = Color.Blue; } else if (i == 4 && j == 3) { grbComponentes.BackColor = Color.Pink; } else if (i == 5 && j == 3) { grbComponentes.BackColor = Color.Yellow; } else if (i == 1 && j == 4) { txtColores.BackColor = Color.Red; txtColores.Text = "El color seleccionado es Rojo"; txtColores.ForeColor = Color.IndianRed; } else if (i == 2 && j == 4) { txtColores.BackColor = Color.Green; txtColores.Text = "El color seleccionado es Verde"; txtColores.ForeColor = Color.LightGreen; } else if (i == 3 && j == 4) { txtColores.BackColor = Color.Blue; txtColores.Text = "El color seleccionado es Azul"; txtColores.ForeColor = Color.LightBlue; } else if (i == 4 && j == 4) { txtColores.BackColor = Color.Pink;

Page 25: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

25 Tutorial de la Aplicación 2

Lenguaje de Programación

txtColores.Text = "El color seleccionado es Rosa"; txtColores.ForeColor = Color.LightPink; } else if (i == 5 && j == 4) { txtColores.BackColor = Color.Yellow; txtColores.Text = "El color seleccionado es Amarillo"; txtColores.ForeColor = Color.LightYellow; } else if (i == 1 && j == 5) { pcbImagen.Image = imageList1.Images[3]; } else if (i == 2 && j == 5) { pcbImagen.Image = imageList1.Images[0]; } else if (i == 3 && j == 5) { pcbImagen.Image = imageList1.Images[2]; } else if (i == 4 && j == 5) { pcbImagen.Image = imageList1.Images[4]; } else if (i == 5 && j == 5) { pcbImagen.Image = imageList1.Images[1]; } }

Codificación de btnRegresar

private void btnRegresar_Click(object sender, EventArgs e) { frmMenu m=new frmMenu(); m.Show(); this.Visible = false; }

Page 26: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

26 Tutorial de la Aplicación 2

Lenguaje de Programación

Codificación de chkRojo (CheckBox con etiqueta de texto Rojo)

private void chkRojo_CheckedChanged(object sender, EventArgs e) { if (chkRojo.Checked == true) { i = 1; Desactivar_CheckBox(); opciones(); } }

Codificación de chkVerde (CheckBox con etiqueta de texto Verde)

private void chkVerde_CheckedChanged(object sender, EventArgs e) { if (chkVerde.Checked == true) { i = 2; Desactivar_CheckBox(); opciones(); } }

Codificación de chkAzul (CheckBox con etiqueta de texto Azul)

private void chkAzul_CheckedChanged(object sender, EventArgs e) { if (chkAzul.Checked == true) { i = 3; Desactivar_CheckBox(); opciones(); } }

Codificación de chkRosa (CheckBox con etiqueta de texto Rosa)

private void chkRosa_CheckedChanged(object sender, EventArgs e) { if (chkRosa.Checked == true) { i = 4; Desactivar_CheckBox(); opciones(); } }

Page 27: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

27 Tutorial de la Aplicación 2

Lenguaje de Programación

Codificación de chkAmarillo (CheckBox con etiqueta de texto Amarillo)

private void chkAmarillo_CheckedChanged(object sender, EventArgs e) { if (chkAmarillo.Checked == true) { i = 5; Desactivar_CheckBox(); opciones(); } }

Codificación de rdbLabel (RadioButton con etiqueta de texto Label)

private void rdbLabel_CheckedChanged(object sender, EventArgs e) { if (rdbLabel.Checked) { j = 1; opciones(); } }

Codificación de rdbColores(RadioButton con etiqueta de texto GroupBoxColores)

private void rdbColores_CheckedChanged(object sender, EventArgs e) { if (rdbColores.Checked) { j = 2; opciones(); } }

Codificación de rdbComponentes(RadioButton con etiqueta de texto GroupBoxComponentes)

private void rdbComponentes_CheckedChanged(object sender, EventArgs e) { if (rdbComponentes.Checked) { j = 3; opciones(); } }

Page 28: APLICACION2 turorial

I.S.C. Luz María Feregrino Martínez

28 Tutorial de la Aplicación 2

Lenguaje de Programación

Codificación de rdbTextBox (RadioButton con etiqueta de texto TextBox)

private void rdbTextBox_CheckedChanged(object sender, EventArgs e) { if (rdbTextBox.Checked) { j = 4; opciones(); } }

Codificación de rdbPictureBox (RadioButton con etiqueta de texto PictureBox)

private void rdbPictureBox_CheckedChanged(object sender, EventArgs e) { if (rdbPictureBox.Checked) { j = 5; opciones(); } }

Codificación de btnDesactivar

private void btnDesactivar_Click(object sender, EventArgs e) { Desactivar_CheckBox1(); Desactivar_RadioButton(); Activar_CheckBox(); grbColores.BackColor = SystemColors.Control; grbComponentes.BackColor = SystemColors.Control; i = 0; j = 0; txtColores.ForeColor = Color.Black; txtColores.BackColor = Color.White; txtColores.Text = "COLORES"; pcbImagen.Image = null; }

NOTA: Recordar que el botón de Desactivar debe restablecer los valores iníciales de los componentes, ya

sea de color de fondo, o colore del texto.