作者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