问题
Dim VoucherOpenConnection As New OleDbConnection
' VoucherOpenConnection = New OleDbConnection
VoucherOpenConnection.ConnectionString = "My Connection String"
Dim VoucherString As String = "My Query"
Dim DAVoucherString As New OleDbDataAdapter(VoucherString, VoucherOpenConnection)
Dim DTVoucherString As New DataTable
DAVoucherString.Fill(DTVoucherString)
If DTVoucherString.Rows.Count <> 0 Then
cmbCategory.Text = DTVoucherString.Rows(0).Item(8).ToString
txtDetails.Text = DTVoucherString.Rows(0).Item(2).ToString
txtshop.Text = DTVoucherString.Rows(0).Item(3).ToString
txtAmount.Text = DTVoucherString.Rows(0).Item(4).ToString
txtRemarks.Text = DTVoucherString.Rows(0).Item(5).ToString
txtInvoiceNum.Text = DTVoucherString.Rows(0).Item(11).ToString
txtCashAmt.Text = DTVoucherString.Rows(0).Item(6).ToString
Me.Refresh()
Else
MsgBox("No valid record could be found(Cash)!!")
End If
I have the above code inside a sub procedure and call it from another form. When the sub is called the first time, all the textboxes display the correct values. But when I try again, the values do not update. Putting a breakpoint in the sub reveals that the code is working correctly as hovering the mouse over the textboxes shows the correct values.
I have already tried the following methods to no avail:
Me.Refresh
Me.Update
Textbox.update/refresh
This is in VB.NET 2019.
Edit:Code in the calling form:
Private Sub DGVTotalReport_CellMouseDoubleClick(sender As Object, e As
DataGridViewCellMouseEventArgs) Handles
DGVTotalReport.CellMouseDoubleClick
Dim ExpForm As New ExpenseEntry
My.Settings.TranCodeExpOpen =
DGVTotalReport.Rows(e.RowIndex).Cells(8).Value
If My.Settings.ExpenseForm = False Then
ExpForm.Show()
ExpForm.OpenVoucher()
My.Settings.ExpenseForm = True
Else
My.Settings.ExpenseForm = True
ExpForm.Activate()
ExpForm.OpenVoucher()
ExpForm.Refresh()
End If
End Sub
来源:https://stackoverflow.com/questions/61327703/textbox-not-refreshing