locked
Label.Text not clearing on button click RRS feed

  • Question

  • I have a wird scenario in which when I click the button, the label.text = "" is not executing.  It only happens when I use the Swith operator in the button handler as shows below.  If I remark the Switch routine, the labels clear fine. Basically I want the labels text to clear everytime I lcik the button before anything else in the handler runs.

    private void button1_Click(object sender, EventArgs e)
            {
                label5.Text = ""; label14.Text = ""; label3.Text = ""; label17.Text = "";
                perfDlg cpuD = new perfDlg(cpuutilWorker);
                perfDlg c3D = new perfDlg(c3Worker);
                perfDlg memD = new perfDlg(memWorker);
                perfDlg batD = new perfDlg(batdisWorker);
               
                button1.Enabled = false;
                btnAbort.Enabled = true;
                progressBar1.Visible = true;
                if (checkedListBox1.CheckedIndices.Count == 0)
                {
                    MessageBox.Show("Did you forget to select a test?", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;

                }
                foreach (int indice in checkedListBox1.CheckedIndices)
                {
                    switch (indice)
                    {
                        case 0:
                            label5.Text = cpuD().ToString();
                            break;
                        case 1:
                            label14.Text = memD().ToString();
                            break;
                        case 2:
                            label3.Text = c3D().ToString();
                            break;
                        case 3:
                            label17.Text = batD().ToString();
                            break;
                        default:
                           
                            break;

                    }
                  
                }

                reInitialize();
                              
            }


    NR
    Sunday, April 12, 2009 5:28 AM

Answers

All replies

  • Hi highlander,

    Thank you for visiting the Microsoft forum. This forum focuses on Perfmon and diagnostic tools. I am moving your question to the moderator forum ("Where is the forum for..?"). The owner of the forum will direct you to a right forum.

    Thanks.
    Kukjin Lee

    Sunday, April 12, 2009 4:03 PM
  • Hi,

    Thank you for your post!  I would suggest posting your question in one of the asp.net Forums HomeASP.NET Forums » General ASP.NET » Web Forms located here: 

    http://forums.asp.net/18.aspx

    Hope this helps you.

    Have a great day!

    Monday, April 13, 2009 5:04 AM