user1516790
user1516790

Reputation: 29

text box not being populated VB.net

I am using vb.net to develop a simple desktop application. fillfeilds is a public function being called from another class. The function is being called but the value of the textboxes doesn't change. But when I call Button1_Click which in turn calls fillfeilds the routine works fine.

I would be most grateful if anyone could guide me as to what I am doing wrong as I do not understand this behavior.

Thanks.

Public Sub fillFeilds()

        FirstNamePri.Text = "lll"
        FirstNamePri.Text = "lll"
        LastNameAlt.Text = "kkkk"


    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        FirstNamePri.Text = "lll"

        fillFeilds()
    End Sub

'class that calls fillfeild() function

Public Class MainCust

      Dim cust As New CustInfo
    MainWindow.MainPanel.Controls.Add(cust)

    Dim rec As New Customer

    Dim dataArr As ArrayList = rec.getFirstCust()

    Dim customer As New CustInfo
    customer.fillFeilds(dataArr)


End Sub

End Class

Upvotes: 0

Views: 253

Answers (2)

Steven Doggart
Steven Doggart

Reputation: 43743

You are creating two separate instances of CustInfo. You are showing the first one but not the second one. The second one, which is never shown is the one on which you are actually filling the fields. Try this instead:

Dim cust As New CustInfo
MainWindow.MainPanel.Controls.Add(cust)
Dim rec As New Customer
Dim dataArr As ArrayList = rec.getFirstCust()
cust.fillFeilds(dataArr)

Upvotes: 1

Steven Yates
Steven Yates

Reputation: 2480

You may have a threading issue if your calling from another class which is on another thread? Maybe? but i would of though it'll throw and exception. Is it being called on another thread?

Upvotes: 0

Related Questions