[英]how to add many selected items from checkboxes to listbox at same time in vb.net
I want to be able to add many selected items from a checkbox to a listbox at the same time. 我希望能够将一个复选框中的许多选定项目同时添加到列表框中。 This is a sample of the code
这是代码示例
If CheckBox1.Checked Then
choice = "Potato soup"
quantity = Val(txtapp1.Text)
price = "80"
If CheckBox2.Checked Then
choice = "Mini tacos"
quantity = Val(txtapp2.Text)
price = "95"
I want to be able to add choice, quantity, and price for each checkbox to the listbox at the same time. 我希望能够将每个复选框的选择,数量和价格同时添加到列表框中。
Assuming that your listbox is named ListBoxChoices, the code would be following: 假设您的列表框名为ListBoxChoices,则代码如下:
If CheckBox1.Checked Then
choice = "Potato soup"
quantity = Val(txtapp1.Text)
price = "80"
ListBoxChoices.Items.Add(choice)
ListBoxChoices.Items.Add(quantity)
ListBoxChoices.Items.Add(price)
End If
If CheckBox2.Checked Then
choice = "Mini tacos"
quantity = Val(txtapp2.Text)
price = "95"
ListBoxChoices.Items.Add(choice)
ListBoxChoices.Items.Add(quantity)
ListBoxChoices.Items.Add(price)
End If
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.