1 Replies - 718 Views - Last Post: 11 November 2008 - 05:34 PM Rate Topic: -----

#1 teddy2000  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 09-November 08

shopping list

Posted 11 November 2008 - 05:29 PM

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 tut6
{
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            
            String result = " ";
            foreach(string activity in listBox1.SelectedItems)
                {
                 result  = result + activity + "  ";
                 } 
                 textBox1.Text = result + " ";
                
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // textBox1.Text = listBox1.Text;
            // listBox1.Items.Add(textBox1.Text);

            MessageBox.Show(listBox1.Items.Count.ToString());
            textBox1.Clear();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            
            string input = textBox1.Text;
            listBox1.Items.Add(input);
            textBox1.Text = "";
        }

        private void button3_Click(object sender, EventArgs e)
        {
           int items = listBox1.Items.Count;
           textBox2.Text = Convert.ToString(items);
        }

        private void Clearbutton4_Click(object sender, EventArgs e)
        {

            listBox1.Items.Clear();
        }
    }
}



Mod Edit: Please use code tags when posting your code. Code tags are used like so => :code:

Thanks,
PsychoCoder :)

Is This A Good Question/Topic? 0
  • +

Replies To: shopping list

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1634
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: shopping list

Posted 11 November 2008 - 05:34 PM

Are you receiving any errors? Does this code not work that way you intended it? When asking for help there are a couple items that are vital in order for someone to properly help you:

  • Post the code you're having problems with (DONE)
  • Post the exact error you're receiving, if you are receiving one
  • If no error explain what the code is doing versus what you want it to do
  • Post your question in the body of your post, not the description field

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1