修改只读文本框

时间:2018-04-09 15:25:27

标签: vb.net textbox readonly inputbox

我正在尝试创建一个表单,在加载时,会出现一个输入框,以便我可以输入一个库存号。从那里,我想获取库存号,并将其显示为表单上的只读文本框。之后,我希望该用户能够按下他们可以输入另一个库存号的按钮。我遇到的问题是,当我单击允许您输入另一个库存号的按钮时,表单不会使用新信息进行更新。我知道我错过了什么,但我不能把手指放在上面。任何帮助将不胜感激。

在负载上发生这种情况

    Private Sub Contract_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    DocName = C1Report1.Document.DocumentName

    Me.btnPrint.Focus()
    Me.Text = DocName & " - " & DealID
    Try
        Try
            mFormInfo = SetValues(DocName, Me, DealID)
        Catch
        End Try
        myDeal = Infinity.Finance.Calc.Deal.GetDealNumber(DealID)
        myFinance = Infinity.Entity.TotalEntity.GetEntity(myDeal.FinanceCompany)
        myVeh = Infinity.Vehicle.Inventory.VehicleUnit.GetVehicleUnit(myDeal.DealVehicles(0).VehID)
        myDealership = Infinity.CompanyInfo.Company.GetCompany(myDeal.CompanyNumber)
        Dim StkNumber As String = InputBox("Please Enter Stock Number", DocName & " - " & DealID, UltraTextEditor22.Text)
        StkNumber = UltraTextEditor22.Text
        UltraTextEditor22.ReadOnly = True

    Catch
    End Try
    'GetaccesoriesFromObject()
End Sub

Step 1

Step 2

Step 3

这是按钮单击的事件

    Private Sub btnNewStockNum_Click(sender As Object, e As EventArgs) Handles btnNewStockNum.Click
    UltraTextEditor22.Clear()
    Dim NewStkNumber As String = InputBox("Please Enter Stock Number", DocName & " - " & DealID, UltraTextEditor22.Text)
    NewStkNumber = UltraTextEditor22.Text
    UltraTextEditor22.ReadOnly = True
End Sub

1 个答案:

答案 0 :(得分:2)

您正在将检索用户输入的变量值设置为文本框的值。你需要做的恰恰相反:

Dim NewStkNumber As String = InputBox("Please Enter Stock Number", DocName & " - " & DealID, UltraTextEditor22.Text)
UltraTextEditor22.Text = NewStkNumber