none
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