0% found this document useful (0 votes)
31 views6 pages

Listas: Estructura de Datos

The document is source code for a C# program that implements a list data structure. It defines a List class with methods to add items to the list in different positions, sort the list, remove items, and display the list. The program also includes a user interface with text boxes and buttons to allow the user to interact with and manipulate the list.

Uploaded by

Giovanni Salazar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views6 pages

Listas: Estructura de Datos

The document is source code for a C# program that implements a list data structure. It defines a List class with methods to add items to the list in different positions, sort the list, remove items, and display the list. The program also includes a user interface with text boxes and buttons to allow the user to interact with and manipulate the list.

Uploaded by

Giovanni Salazar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

9/16/2017 Listas

Estructura de datos.

Edgar Giovanni Salazar Espinoza


IS16110207
Interfaz

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

namespace Listas
{
public partial class Form1 : Form
{
//Declaraciones juertes 7v7
int ingreso, pocicion;
List<int> lista = new List<int>();
//Eventos
public void VL()
{
listBox1.Items.Clear();
for (int x = 0; x < lista.Count; x++)
{
listBox1.Items.Add(lista[x]);
}
}
public void Final()
{
try
{
ingreso = int.Parse(textBox1.Text);
lista.Add(ingreso);//Final Fantasy
MessageBox.Show("Tu valor se a agragado");
}
catch (Exception)
{
MessageBox.Show("Valor no valido");
}
}
public void Inicio()
{
try
{
ingreso = int.Parse(textBox2.Text);
lista.Insert(0, ingreso);//Final Fantasy
MessageBox.Show("Tu valor se a agragado");
}
catch (Exception)
{
MessageBox.Show("Valor no valido");
}
}
public void Posicin()
{
try
{
pocicion = int.Parse(textBox3.Text) - 1;
ingreso = int.Parse(textBox4.Text);
lista.Insert(pocicion, ingreso);//Final Fantasy
MessageBox.Show("Tu valor se a agragado");
}
catch (Exception)
{
MessageBox.Show("Valor no valido");
}
}
public void BVer()
{
try
{
ingreso = int.Parse(textBox6.Text);

if (textBox6.Text == Convert.ToString(lista.Count))
{
textBox5.Text = Convert.ToString(lista[ingreso - 1]);
}
}
catch(Exception)
{
textBox5.Text = ("Valor.");
}
}
public void Borrar()
{
try
{
ingreso = (int.Parse(textBox6.Text) - 1);
lista.Remove(ingreso);
}
catch (Exception)
{
MessageBox.Show("Valor no valido");
}
}
public void A_Z()
{
lista.Sort();
}
public void Z_A()
{
lista.Reverse();
}
public Form1()
{
InitializeComponent();
}

private void textBox6_TextChanged(object sender, EventArgs e)


{
try
{
ingreso = int.Parse(textBox6.Text);

if (textBox6.Text == Convert.ToString(lista.Count))
{
textBox5.Text = Convert.ToString(lista[ingreso - 1]);
}
}
catch (Exception)
{
textBox5.Text = ("Valor.");
}
}

private void button8_Click(object sender, EventArgs e)


{
Environment.Exit(0);
}

private void Form1_Load(object sender, EventArgs e)


{

private void button1_Click(object sender, EventArgs e)


{
Final();
VL();
textBox1.Clear();
}

private void button2_Click(object sender, EventArgs e)


{
Inicio();
VL();
textBox2.Clear();
}
private void button3_Click(object sender, EventArgs e)
{
Posicin();
VL();
textBox3.Clear();
textBox4.Clear();
}

private void button4_Click(object sender, EventArgs e)


{
Borrar();
VL();
}

private void textBox6_KeyPress(object sender, KeyPressEventArgs e)


{

private void button5_Click(object sender, EventArgs e)


{
try
{
A_Z();
VL();
}
catch (Exception)
{
}
}

private void button6_Click(object sender, EventArgs e)


{
try
{
A_Z();
Z_A();
VL();
}
catch (Exception)
{
}
}

private void button7_Click(object sender, EventArgs e)


{
try
{
lista.Clear();
VL();
}
catch (Exception)
{
}
}
}
}

You might also like