Sie sind auf Seite 1von 3

using System;

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

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

private void Form1_Load(object sender, EventArgs e)


{

private void button1_Click(object sender, EventArgs e)


{
listBox1.Items.Add(textBox1.Text);
textBox1.Text = "";
textBox1.Focus();
}

private void button2_Click(object sender, EventArgs e)


{
for (int i = 0; i < listBox1.Items.Count; i++)
{
listBox2.Items.Add(listBox1.Items[i]);
}
listBox1.Items.Clear();
}

private void button3_Click(object sender, EventArgs e)


{
if (listBox1.SelectedItem != null)
{
listBox2.Items.Add(listBox1.SelectedItem);
listBox1.Items.Remove(listBox1.SelectedItem);
}
else
MessageBox.Show("Seleccione un curso");
}

private void button4_Click(object sender, EventArgs e)


{
if (listBox2.SelectedItem != null)
{
listBox1.Items.Add(listBox2.SelectedItem);
listBox2.Items.Remove(listBox2.SelectedItem);
}
else
MessageBox.Show("Seleccione un curso");
}

private void button5_Click(object sender, EventArgs e)


{
for (int i = 0; i < listBox2.SelectedItems.Count; i++)
{
//listBox1.Items.Add(listBox2.Items[i]);
listBox1.Items.Add(listBox2.SelectedItems[i]);

}
for (int i = listBox2.SelectedItems.Count-1; i >=0; i--)
{
//listBox1.Items.Add(listBox2.Items[i]);
listBox2.Items.Remove(listBox2.SelectedItems[i]);

}
//listBox2.Items.Clear();
}

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)


{
if (char.IsNumber(e.KeyChar))
{
e.Handled = true;
MessageBox.Show("Solo puede ingresar valores de tipo cadena");
}
else if (char.IsLetter(e.KeyChar))
e.Handled = false;
}

private void textBox1_KeyUp(object sender, KeyEventArgs e)


{
if (e.KeyValue == (char)(Keys.Enter))
{
listBox1.Items.Add(textBox1.Text);
textBox1.Text = "";
}
}
}
}

Das könnte Ihnen auch gefallen