C#

Discussion in 'Software' started by arora.saurabh, May 31, 2008.

  1. arora.saurabh

    arora.saurabh

    Joined:
    May 31, 2008
    Messages:
    1
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Collections;

    namespace PERPOTIONATE
    {
    public partial class PERPORTIONATE : Form
    {
    ArrayList arr = new ArrayList();
    ArrayList arr1 = new ArrayList();
    float fValueToAdd = 0;
    float fValue1ToAdd = 0;
    float P, D, M;
    int R,i,g;

    public PERPORTIONATE()
    {
    InitializeComponent();
    }


    private void button1_Click(object sender, EventArgs e)
    {
    textBox1.Focus();
    if (textBox1.Text.Trim().Length == 0)
    {
    MessageBox.Show("PDL Cannot be left blank.");
    return;
    }
    try
    {
    fValueToAdd = float.Parse(textBox1.Text);
    }
    catch
    {
    MessageBox.Show("Please enter valid value.");
    textBox1.Text = string.Empty;
    return;
    }
    arr.Add(fValueToAdd);
    listBox1.Items.Add(fValueToAdd);
    //MessageBox.Show(textBox1.Text + " successfully added.");
    textBox1.Text = string.Empty;
    }

    private void button2_Click(object sender, EventArgs e)
    {
    textBox1.Focus();
    float fSum = 0;
    foreach (float f in arr)
    {
    fSum = fSum + f;
    }
    textBox1.Text=(fSum.ToString());
    }

    // DL*******************

    private void button4_Click(object sender, EventArgs e)
    {
    textBox2.Focus();
    if (textBox2.Text.Trim().Length == 0)
    {
    MessageBox.Show("DL Cannot be left blank.");
    return;
    }
    try
    {
    fValue1ToAdd = float.Parse(textBox2.Text);
    }
    catch
    {
    MessageBox.Show("Please enter valid value.");
    textBox2.Text = string.Empty;
    return;
    }
    arr1.Add(fValue1ToAdd);
    listBox2.Items.Add(fValue1ToAdd);
    // MessageBox.Show(textBox2.Text + " successfully added.");
    textBox2.Text = string.Empty;
    }

    private void button5_Click(object sender, EventArgs e)
    {
    textBox2.Focus();
    float fSum1 = 0;
    foreach (float f in arr1)
    {
    fSum1 = fSum1 + f;
    }
    textBox2.Text = (fSum1.ToString());
    }

    //CLEAR ALL***************
    private void button3_Click(object sender, EventArgs e)
    {
    textBox1.Focus();
    if (MessageBox.Show("Are you sure you want to clear reuslt", "Alert", MessageBoxButtons.YesNo) == DialogResult.Yes)
    {
    listBox1.Items.Clear();
    listBox2.Items.Clear();
    textBox1.Clear();
    textBox2.Clear();
    textBox3.Clear();
    textBox4.Clear();
    arr.Clear();
    arr1.Clear();
    }

    }
    private void button6_Click(object sender, EventArgs e)
    {
    textBox4.Focus();
    float P = float.Parse(textBox1.Text);
    float D = float.Parse(textBox2.Text);
    float M = float.Parse(textBox3.Text);
    float fSum2 = 0;
    fSum2 = P/D*M;
    textBox4.Text = (fSum2.ToString());
    }

    private void Form1_Load(object sender, EventArgs e)
    {
    textBox1.Focus();

    }
    private void button7_Click(object sender, EventArgs e)
    {
    if (textBox1.Text != null && textBox2.Text != null && textBox3.Text != null)
    {
    button6.Enabled = false;
    }
    else
    {
    button6.Enabled = true;
    }
    }

    private void listBox1_DoubleClick(object sender, EventArgs e)
    {
    ListBox.SelectedObjectCollection s = listBox1.SelectedItems;
    while (s.Count > 0)
    listBox1.Items.Remove(s[0]);
    arr.Remove(listBox1.SelectedItem(s));

    }

    private void listBox2_DoubleClick(object sender, EventArgs e)
    {
    ListBox.SelectedObjectCollection a = listBox2.SelectedItems;
    while (a.Count > 0)
    listBox2.Items.Remove(a[0]);
    }


    }


    }



    HOW DO I UPDATE ARRAYLIST ACCORDING TO LIST BOX?
    I WISH TO REMOVE FROM ARRAYLIST ACCORDING TO LISTBOX
     
    arora.saurabh, May 31, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page