[問題] combobox輸出

看板C_Sharp (C#)作者 (接近神的男人)時間14年前 (2011/08/20 16:12), 編輯推噓1(103)
留言4則, 3人參與, 最新討論串1/1
想用基礎寫法 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { comboBox1.Text = comboBox1.Items[0].ToString(); label2.Text = "21"; label4.Text = "100"; label6.Text = "111"; comboBox1.Text = comboBox1.Items[1].ToString(); label2.Text = "27"; label4.Text = "40"; label6.Text = "222"; //comboBox1.Items[2].ToString(); //label2.Text = "12"; //label4.Text = "300"; //label6.Text = "50"; } 以上我想選擇Items裡面不同選項顯示不同數據 可是用comboBox1.Text = comboBox1.Items[0].ToString();寫法 會造成無線迴圈/遞迴 用comboBox1.Items[0].ToString();只會顯示最後一組數據 我想加上if(comboBox1.Text = comboBox1.Items[0].ToString()) 就顯示錯誤 無法將型別 'string' 隱含轉換為 'bool' C#新手上路~多多包涵 -- ◢██◣█▇▆▅▄ ◣ ◢ ◢█◣◢█◣ ┐│ ╔║║ ◣ ◢▉ ◢█◣ ◢█◣█ █◢█◣███████▆◣ │┤ ║║║ ◥██◤ ▊ ▋ █ ▋▄◤◥█◤▌▄◤◥████◤ ▌ ▋ 人│ ║╠╣ ◣◢▋ ◥█▋▌◥▄▃ █ ◥▅▂ ◥██◤ ▌ ▊ │ ║║║ ▅▅◥◤ ╰─ ╚║║ —— The Red Captain Gee~Gee~Gee~Gee Tae~Tae~Tae~Tae~Tae~yeon~by jimmy508 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.118.114.74

08/20 17:05, , 1F
== -.-
08/20 17:05, 1F

08/20 17:08, , 2F
if(a=b) 當然這個if,一直都會執行啊
08/20 17:08, 2F

08/20 17:09, , 3F
判斷式要用 == 兩個等於
08/20 17:09, 3F

08/20 17:16, , 4F
感謝大神~
08/20 17:16, 4F
文章代碼(AID): #1EJsnTGX (C_Sharp)
文章代碼(AID): #1EJsnTGX (C_Sharp)