Michael

Michael

  • NA
  • 20
  • 0

Trouble

Feb 27 2008 10:08 PM
Hi I was messing around with some code.
namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            label1.Text = listBox2.SelectedItem.ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            listBox2.Items.Add("test");
            listBox2.Items.Add("Hello");
        }
    }
}

Basicly when i click the button it will add the text to the list box and then when I click on the items in the list box it should show that selected text in the label1    but for some reason it doesnt for me.  It doesnt even call the listBox2_SelectedIndexChanged method when i selected a new item in the list box.  I have used this code before in Windows XP and worked great but now in Vista it seems to have a big problem.   Anyone know whats going on?

Answers (1)