简体   繁体   English

在组合框的选择更改事件上填充文本框中的值?

[英]Populating values in text box on the selection changed event of Combo Box?

I have a wpf application which has combo box and multiple text boxes. 我有一个wpf应用程序,它具有组合框和多个文本框。

On the window load event the combo box is filled with the Employee IDs. 在窗口加载事件中,组合框将填充员工ID。 When I select any ID then the below text boxes should display the name, city, zip, country of the selected "Id". 当我选择任何ID时,下面的文本框应显示所选“ Id”的名称,城市,邮政编码,国家/地区。 I did wrote the below code for filling in the values in text boxes. 我确实写了下面的代码来填写文本框中的值。 Private Sub dataview1(ByVal GUID As String) Try 私有子dataview1(ByVal GUID作为字符串)试试

        Dim viewDs As New DataSet()
        Dim Query As String
        Query = "Select * from tblEmployeeInfo Where ID = '" & GUID.Trim & "'"
        viewDs = GetData(Query, True)

        Dim dv As DataView = New DataView(viewDs.Tables(0))
        Dim Notify As String = String.Empty
        If dv.Count > 0 Then

            If Not IsDBNull(dv(0)("ID")) Then
                txtGUID.Text = dv(0)("ID")
            Else
                txtGUID.Text = String.Empty
            End If

           If Not IsDBNull(dv(0)("StreetName"))     Then
                txtStName.Text = dv(0)("StreetName")
            Else
                txtStName.Text = String.Empty
            End If
        End If
    Catch ex As Exception
        MsgBox("No Values Found")
    End Try
End Sub

And called the above function on Selection Changed Event of Combo Box as below: 并在组合框的选择更改事件上调用了以下函数,如下所示:

Private Sub ID CB_SelectionChanged(sender As System.Object, e As System.Windows.Controls.SelectionChangedEventArgs) Handles IDCB.SelectionChanged
    StreetCB.IsEnabled = False
   DataView1(IDCB.SelectedItem)

Though it hits the ViewMode Function but it never populates any values in my text boxes. 尽管它命中了ViewMode Function,但它从未在我的文本框中填充任何值。

Am I missing any thing in it? 我是否想念其中的任何东西?

Is there any way I could achieve? 有什么办法可以实现?

Any help will be much appreciated. 任何帮助都感激不尽。

Thank you so much! 非常感谢!

Though it hits the ViewMode Function but it never populates any values in my text boxes. 尽管它命中了ViewMode Function,但它从未在我的文本框中填充任何值。

Step through this in the debugger. 在调试器中逐步解决。 This could happen if your query returns no results, which is, I suspect, the issue in this case. 如果您的查询未返回任何结果,则可能会发生这种情况,我怀疑这是这种情况下的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM