Textbox not refreshing

半世苍凉 提交于 2021-02-11 15:50:02

问题


 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!