我想知道在我的项目中使用什么控件是Listview还是listbox ???。 我在我的项目上有一个comboBox控件,我想要做的是当我在我的组合框中选择1个项目时它会自动添加到listbox或listview上,当我选择多个项目时,我想将它添加到listbox或listview on newline上。 ..
这很简单,请帮我在列表框或列表视图中做到这一点。谢谢!
I want to know what control to be use on my project is it Listview or listbox???. I have a comboBox control on my project what I want to do is when I selected 1 item on my combobox it will automatically add on listbox or listview and when I selected more than 1 item I want to add it on listbox or listview on newline...
Is it simple, please help me to do that in listbox or listview..thanks!
最满意答案
Listbox > Is for viewing too but user can select it Listview > Is for viewing only, user cannot select also it viewing by five view directly cause it's for viewing only如果您的项目希望从Combobox选择的内容中查看列表,那么您只需选择列表视图,但如果您想要查看,用户也可以选择它,更好地使用列表框,这取决于您。 此外,您可以通过将鼠标光标对准工具来了解工具的工作方式,然后它会弹出一个工具提示,用于编写工具的内容。
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged ListView1.Items.Add(ComboBox1.SelectedIndex) End Sub这是在listview中查看您在组合框中选择的内容的代码
要清除列表视图或列表框中的所有项目,只需写入form_load即可
Listview.items.clear为什么我在表单加载中说,导致列表只是为了查看,当然每次表单开始运行时,都需要空白列表,所以最好放在表单加载
UPDATE
删除列表框中的选定索引
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged ListBox1.Items.Remove(ListBox1.SelectedItem) End Sub Listbox > Is for viewing too but user can select it Listview > Is for viewing only, user cannot select also it viewing by five view directly cause it's for viewing onlyIf your project wanted the list to be viewing from what have been select by Combobox, then you just pick List View, but if you want for viewing also user can select it, better use listbox, so it's up to you. Also you can know how the Tools work by focus your mouse cursor to the tool, then it will pop up an tooltip that write what the tool for.
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged ListView1.Items.Add(ComboBox1.SelectedIndex) End SubThat is the code to viewing in listview for what you select in combobox
For clearing all the item in the Listview or listbox, just write to your form_load
Listview.items.clearWhy i said in form load, cause the list just for viewing, of course every time the form begin to run, it will need blank list, so the best is put in form load
UPDATE
To remove the selected index in listbox
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged ListBox1.Items.Remove(ListBox1.SelectedItem) End Sub更多推荐
发布评论