本文介绍了在ListBox1中选择索引,并且在ListBox2中也选择相应的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

还选择了ListBox1中的选择索引和ListBox2中的相应索引

例如:
listbox1和listbox2包含6个项目.

现在我要选择listbox1的第4个项目,然后listbox2自动将选择内容更改为listbox2的第4个项目.
您能帮我吗?

Select Index In ListBox1 And Corresponding Index In ListBox2 Is Also Selected

eg:
listbox1 & listbox2 contain 6 items.

now i want select 4th item of listbox1, then listbox2 automatically change the selection to 4th item of listbox2.
can u help me.

推荐答案

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        If ListBox1.SelectedIndex < ListBox2.Items.Count Then ListBox2.SelectedIndex = ListBox1.SelectedIndex
End Sub


Private Sub ListBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox2.SelectedIndexChanged
       ListBox2.SelectedIndex = ListBox1.SelectedIndex
   End Sub


这篇关于在ListBox1中选择索引,并且在ListBox2中也选择相应的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 23:37