2016-05-15 56 views
0

當前我在學校項目中使用了下面這些代碼的GUI:我想讓某些標籤/文本框在點擊按鈕提交後出現,我該怎麼做?謝謝!關於c#圖形用戶界面(點擊按鈕)某些標籤會出現

using System.Windows.Forms; 

namespace SchoolProject 
{ 
    public partial class Clothes : Form 
    { 
     public Clothes() 
     { 
      InitializeComponent(); 
     } 

     private void groupBox1_Enter(object sender, EventArgs e) 
     { 

     } 

     private void button1_Click(object sender, EventArgs e) 
     { 
      double Red1 = 13.00; 
      double Blue1 = 12.00; 
      double Green1 = 11.00; 

      double Red2 = 6.00; 
      double Blue2 = 7.00; 
      double Green2 = 8.00; 
      double total; 


      if (rbnRed1.Checked && rbnRed2.Checked) 
      { 
       total = Red1 + Red2; 
       MessageBox.Show("Red Tee & Red Crop Tee" + "Total:$ " + total.ToString("0.00")); 
      } 

      if (rbnRed1.Checked && rbnBlue2.Checked) 
      { 
       total = Red1 + Blue2; 
       MessageBox.Show("Red Tee & Blue Crop Tee" + "Total: $" + total.ToString("0.00")); 
      } 

      if (rbnRed1.Checked && rbnGreen2.Checked) 
      { 
       total = Red1 + Green2; 
       MessageBox.Show("Red Tee & Green Crop Tee" + "Total:$ " + total.ToString("0.00")); 
      } 
      //======= 

      if (rbnBlue1.Checked && rbnRed2.Checked) 
      { 
       total = Blue1 + Blue2; 
       MessageBox.Show("Blue Polo & Blue Crop Tee" + "Total:$ " + total.ToString("0.00")); 
      } 

      if (rbnBlue1.Checked && rbnBlue2.Checked) 
      { 
       total = Red1 + Blue2; 
       MessageBox.Show("Red Polo Tee & Blue Crop Tee" + "Total: $" + total.ToString("0.00")); 
      } 

      if (rbnBlue1.Checked && rbnGreen2.Checked) 
      { 
       total = Red1 + Green2; 
       MessageBox.Show("Red Polo Tee & Green Crop Tee" + "Total:$ " + total.ToString("0.00")); 
      } 
      //=========== 

      if (rbnGreen1.Checked && rbnRed2.Checked) 
      { 
       total = Red1 + Red2; 
       MessageBox.Show("Red Polo Tee & Red Crop Tee" + "Total:$ " + total.ToString("0.00")); 
      } 

      if (rbnGreen1.Checked && rbnBlue2.Checked) 
      { 
       total = Red1 + Blue2; 
       MessageBox.Show("Red Polo Tee & Blue Crop Tee" + "Total: $" + total.ToString("0.00")); 
      } 

      if (rbnGreen1.Checked && rbnGreen2.Checked) 
      { 
       total = Red1 + Green2; 
       MessageBox.Show("Red Polo Tee & Green Crop Tee" + "Total:$ " + total.ToString("0.00")); 
      } 




     } 

     private void groupBox2_Enter(object sender, EventArgs e) 
     { 

     } 
    } 
} 

回答

0

讓你展現lable1 lable2顯示上單擊Button1 左右。你喜歡這個。 在窗體加載事件中添加以下代碼

private void Form1_Load(object sender, EventArgs e) 
    { 
     lable1.Visible = false; 
     lable2.Visible = false; 
    } 

和Button1的Click事件

private void button1_Click(object sender, EventArgs e) 
    { 
     lable1.Visible = true; 
     lable2.Visible = true; 
    } 
+0

謝謝!編碼還是新的,它起作用:> –