作者iamso1 (可愛活潑小獸兒)
看板Visual_Basic
標題[.NET] 將多個checkbox的名稱加入listbox
時間Tue Jul 7 18:18:10 2009
大家好~
抱歉 有問題想要問問大家>"<
是這樣的..
我做的是類似購物網的東西
裡面有一個tabcontrol 其中有groupbox 並且在groupbox中有很多checkbox
然後在旁邊有一個listbox
我寫的程式碼是這樣的:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
ListBox1.Items.Clear()
For Each ctrlb As Control In Me.Controls
If TypeOf (ctrlb) Is TabControl Then
For Each ctrl As Control In ctrlb.Controls
If TypeOf (ctrl) Is TabPage Then
For Each ctrla As Control In ctrl.Controls
If TypeOf (ctrla) Is GroupBox Then
For Each ctrln As Control In ctrla.Controls
If TypeOf (ctrln) Is CheckBox Then
If CType(ctrln, CheckBox).Checked =
True Then
ListBox1.Items.Add(123)
End If
End If
Next
End If
Next
End If
Next
End If
Next
End Sub
期中的問題就是
我雖然從tabcontrol中找到checkbox的checked為true的有哪些
但是我最後我listbox的item加入的部分 我希望的是加入被選到的checkbox的名稱
但是不知道怎麼抓到..
(我在程式碼裡面是打加入123)
請問有人可以幫幫忙嗎@Q@
--
◢█ █◣ 討厭~下面還沒熟~不能吃啦~
◢ ◣ >\\\<█ ◢◢ ◣
◢◢◣ ◣ ~●──●~ ◢◢ ◣
◣ ◣█ ██ ◢ ─ ▉
◢ ◣▄ █▄ ─ ─ ◢
◢ ◢◣ ▆▆▆▆▆ ██ ─ ◢ψQSWEET
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.128.142.113
1F:→ MOONRAKER:.text,跟右邊property list上面一樣 07/07 19:19
2F:→ iamso1:不懂@@" 請問是哪個地方加上.text呢?? 07/07 19:36
3F:→ Peruheru:checkbox.text 一樓是這個意思 07/07 19:40
4F:→ MOONRAKER:ctrln.text 07/07 19:40
5F:→ iamso1:回三樓~ 直接用checkbox.text的方式我之前用過 沒辦法 07/07 20:00
6F:→ iamso1:至於ctrln.text我倒是沒想到@Q@ 明天試試看 07/07 20:01
7F:→ iamso1:不過想另外問一下 什麼是property list@@a 07/07 20:01
8F:→ iamso1:在這裡先謝謝大家>Q<b 07/07 20:06
9F:→ iamso1:所以ctrln.text是加在listbox.item.add(這裡面)麻@@ 07/07 20:07
10F:推 Peruheru:property list 是指你選擇一項物件,右邊的[屬性]視窗 07/07 20:25
11F:推 iamsor:了解~^^ 07/07 20:42