0% found this document useful (0 votes)
28 views2 pages

Using Using Using Using Using Using Using Using Using Namespace Public Partial Class Public

This document contains the code for a Windows forms application with two list boxes (l1 and l2) and four buttons. Button1 moves a selected item from l1 to l2, and button3 moves from l2 to l1. Button2 clears l1 and adds all its items to l2, and button4 vice versa. The buttons also change color on mouse enter/leave.

Uploaded by

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

Using Using Using Using Using Using Using Using Using Namespace Public Partial Class Public

This document contains the code for a Windows forms application with two list boxes (l1 and l2) and four buttons. Button1 moves a selected item from l1 to l2, and button3 moves from l2 to l1. Button2 clears l1 and adds all its items to l2, and button4 vice versa. The buttons also change color on mouse enter/leave.

Uploaded by

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

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 WindowsFormsApplication7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
if (l1.SelectedIndex != -1)
{
l2.Items.Add(l1.SelectedItem);
l1.Items.Remove(l1.SelectedItem);
}
else
{
MessageBox.Show("NO Item is selected");
}
}

private void button3_Click(object sender, EventArgs e)


{
if (l2.SelectedIndex != -1)
{
l1.Items.Add(l2.SelectedItem);
l2.Items.Remove(l2.SelectedItem);
}
else
{
MessageBox.Show("NO Item is selected");
}
}

private void button2_Click(object sender, EventArgs e)


{
for (int i = 0; i < l1.Items.Count; i++)
{

l2.Items.Add(l1.Items[i].ToString());
}

l1.Items.Clear();

private void button4_Click(object sender, EventArgs e)


{
for (int i = 0; i < l2.Items.Count; i++)
{

l1.Items.Add(l2.Items[i].ToString());
}

l2.Items.Clear();
}

private void button1_MouseEnter(object sender, EventArgs e)


{
button1.BackColor = Color.Blue;
}

private void button1_MouseLeave(object sender, EventArgs e)


{
button1.BackColor = Color.Transparent;
}

private void button2_MouseEnter(object sender, EventArgs e)


{
button2.BackColor = Color.Red;
}

private void button2_MouseLeave(object sender, EventArgs e)


{
button2.BackColor = Color.Transparent;
}

private void button3_MouseEnter(object sender, EventArgs e)


{
button3.BackColor = Color.Green;
}

private void button3_MouseLeave(object sender, EventArgs e)


{
button3.BackColor = Color.Transparent;
}

private void button4_MouseEnter(object sender, EventArgs e)


{
button4.BackColor = Color.Yellow;
}

private void button4_MouseLeave(object sender, EventArgs e)


{
button4.BackColor = Color.Transparent;
}

private void Form1_Load(object sender, EventArgs e)


{

}
}
}

You might also like