Tuesday, 27 November 2012

Program using List box

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

namespace usinglistbox
{
public partial class Form1 : Form
{
int m1, m2, tot;
public Form1()
{
InitializeComponent();
}

private void clear_Click(object sender, EventArgs e)
{
textBox1.Text="";
textBox2.Text="";
textBox3.Text="";
textBox4.Text="";
textBox5.Text = "";

}

private void add_Click(object sender, EventArgs e)
{
m1 = int.Parse(textBox4.Text);
m2 = int.Parse(textBox5.Text);
tot = m1 + m2;

listBox1.Items.Add(textBox1.Text);
listBox2.Items.Add(textBox2.Text);
listBox3.Items.Add(textBox3.Text);
listBox4.Items.Add(textBox4.Text);
listBox5.Items.Add(textBox5.Text);
listBox6.Items.Add(tot);
}

private void remove_Click(object sender, EventArgs e)
{
int x;
x = listBox1.SelectedIndex;
listBox1.Items.RemoveAt(x);
listBox2.Items.RemoveAt(x);
listBox3.Items.RemoveAt(x);
listBox4.Items.RemoveAt(x);
listBox5.Items.RemoveAt(x);
listBox6.Items.RemoveAt(x);


}


}
}

No comments:

Post a Comment