0
如果頁面上一個選項卡中的數據更改,我們需要看到更新如果用戶更改某些內容並移動到另一個選項卡...WPF ComboBox.ItemsSource進入循環,如果數據返回初始化外
這工作完全與網格
Private Async Sub Telephone_ReturnData()
Try
Dim DGV As CustomControl.DGVx = Prospect_Grid.FindName("Telephone_DGV")
strSQL = "SELECT Prospect_TelephoneCalls.Transaction_ID as 'ID', "
strSQL += "Prospect_Contacts.Contact_FirstName + ' ' + Prospect_Contacts.Contact_Surname as 'Contact', "
strSQL += "Prospect_TelephoneCalls.Call_Date as 'Date' "
strSQL += "FROM Prospect_TelephoneCalls "
strSQL += "JOIN Prospect_Contacts ON Prospect_TelephoneCalls.Contact_ID = Prospect_Contacts.Contact_ID "
strSQL += "WHERE Prospect_TelephoneCalls.Prospect_ID = " & Prospect_ID
strSQL += " ORDER BY Prospect_TelephoneCalls.Call_Date DESC"
Await Task.Run(Sub()
Using vService As New Service1Client
Using DS As DataSet = vService.ReturnDataSetHAS(strSQL)
TelephoneDT = DS.Tables(0).Copy
End Using
End Using
End Sub)
DGV_ColumnDefinitions(DGV, TelephoneDT)
DGV.ItemsSource = TelephoneDT.DefaultView
Dim vRecords As Integer = TelephoneDT.Rows.Count
Dim vOutput As String = "One record returned..."
If Not vRecords = 1 Then
vOutput = vRecords & " records returned..."
End If
PageStatusBarLoaded(Prospect_Grid, vOutput)
Catch ex As Exception
EmailError(ex)
End Try
End Sub
端部區域
但做一個組合框同樣的事情是進入和無限循環和應用程序凍結。
Private Async Sub ReloadTelephoneContacts()
Try
'If TelephoneContactsDT Is Nothing Then
' TelephoneContactsDT = New DataTable
'Else
' TelephoneContactsDT.Dispose()
' TelephoneContactsDT = New DataTable
'End If
'' Dim DT As New DataTable
'With TelephoneContactsDT.Columns
' .Add("ID", GetType(Integer))
' .Add("Name", GetType(String))
'End With
'With TelephoneContactsDT.Rows
' .Add(0, "Select Contact")
'End With
Await Task.Run(Sub()
strSQL = "Select Contact_ID as 'ID', Contact_FirstName + ' ' + Contact_Surname as 'Name' FROM Prospect_Contacts WHERE Prospect_ID = " & Prospect_ID
Using vService As New Service1Client
Using DS As DataSet = vService.ReturnDataSetHAS(strSQL)
TelephoneContactsDT = DS.Tables(0).Copy
'For Each Row As DataRow In DS.Tables(0).Rows
' With TelephoneContactsDT.Rows
' .Add(Row("ID"), ReturnText(Row("Name")))
' End With
'Next
End Using
End Using
End Sub)
Dim SpokeToCB As CustomControl.ComboCBx = Prospect_Grid.FindName("Telephone_SpokeToCB")
'SpokeToCB.ItemsSource = Nothing
With SpokeToCB
.ItemsSource = TelephoneContactsDT.DefaultView
.DisplayMemberPath = "Name"
.SelectedValuePath = "ID"
.SelectedIndex = 0
End With
PageStatusBarRightChangeText(Prospect_Grid, "Telephone text")
Catch ex As Exception
EmailError(ex)
End Try
End Sub
任何想法如何克服這一點?
如果在初始化的運行,但需要更新
感謝