Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
vb.net cboboxes从一个中选择一个值,并从另一个中自动选择索引号_Vb.net_Visual Studio 2010_Combobox - Fatal编程技术网

vb.net cboboxes从一个中选择一个值,并从另一个中自动选择索引号

vb.net cboboxes从一个中选择一个值,并从另一个中自动选择索引号,vb.net,visual-studio-2010,combobox,Vb.net,Visual Studio 2010,Combobox,嘿,当用户使用第一个cbobox的索引从第一个cbobox中选择一个名称时,我正在尝试从第二个cbobox中自动选择电子邮件值。(所有值彼此正好对齐) 这是我当前的代码: Private Sub cmbAnalyst_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbAnalyst.SelectedIndexChanged theAName = cmbAn

嘿,当用户使用第一个cbobox的索引从第一个cbobox中选择一个名称时,我正在尝试从第二个cbobox中自动选择电子邮件值。(所有值彼此正好对齐)

这是我当前的代码:

Private Sub cmbAnalyst_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbAnalyst.SelectedIndexChanged
    theAName = cmbAnalyst.Text
    Dim intSelectedIndex = cmbAnalyst.SelectedIndex

    cboEmails.SelectedValue = intSelectedIndex
End Sub
我的索引很好(intSelectedIndex),但我无法让它在第二个cbobox中选择电子邮件。当我选择一个名字时,没有任何东西可以选择

任何帮助都会很好o)


David

您还必须在第二个组合框中使用SelectedIndex

Private Sub cmbAnalyst_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbAnalyst.SelectedIndexChanged
    theAName = cmbAnalyst.Text
    Dim intSelectedIndex = cmbAnalyst.SelectedIndex

    cboEmails.SelectedIndex = intSelectedIndex
End Sub