2014-02-25 201 views
0

我的窗体上有一个组合框。这与表格中包含该人员的职员姓名和职员参考资料。从ComboBox中读取值并将其放入文本框中

组合框中显示了所有员工的名字和选择应创造值staffRef,我希望能够选择的名称和StaffRef被填充到文本框中。

到目前为止,我只能得到这个词StaffRef去那里。

这是我的代码,希望你能帮助!

 Private Sub frmAddCar_Load(sender As System.Object, e As System.EventArgs) 
     Handles MyBase.Load 


     'TODO: This line of code loads data from the 'namesstolenpool' table and drops 
     it into the combobox(Driver_Name). 

     Dim table As DataTable 
     table = BusinessData.VerifierLogic.Load("namesstolenpool", 
     New Dictionary(Of String, Object)) 
     Driver_name.DataSource = table 
     Driver_name.DisplayMember = "displayname" 
     Driver_name.ValueMember = "staffref" 

    End Sub 

    'This should display the "value" of the combobox in the textbox. 


    Private Sub Driver_name_SelectedIndexChanged(sender As System.Object 
    , e As System.EventArgs) Handles Driver_name.SelectedIndexChanged 

     TextBox1.Text = Driver_name.ValueMember 

    End Sub 

End Class 

回答

0

尝试喜欢上了这

Private Sub Driver_name_SelectedIndexChanged(sender As System.Object 
    , e As System.EventArgs) Handles Driver_name.SelectedIndexChanged 

     TextBox1.Text = Driver_name.SelectedItem("staffref") 

    End Sub 
+0

现货!谢谢! –

+0

欢迎@PaulBedford – Sathish

相关问题