D
D
Darkzenon2018-05-30 11:57:22
Visual Basic
Darkzenon, 2018-05-30 11:57:22

How to update elements in control on form in vb.net?

In vb.net there is a form, control with textbox is built in it.
When you click on a button on a form or a button on a control, you can insert a value into a textbox, and the value appears in it.
BUT
If the same code to put in procedure which works on event.
The data in the textbox is updated (checked by accessing the text textbox value), but is not visually displayed on the form.
What could be the snag?

Form1
‘Это работает (значение подставляется в textbox)
Public Class MainForm
    Public Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        UserControl21. txt_user_name.Text = "name"
   End Sub
End class

‘Это не работает. (значение реально меняется, но визуально textbox остается пустым)
Public Sub LoadUserInfo(user_id As String)
UserControl21.txt_user_name.Text = "name"
End Sub

Control
Public Class UserControl2
  ‘Так работает (кнопка встроенная в сам control)
    Public Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        txt_user_name.Text = "name"
    End Sub

‘Так вызывается процедура обновления страницы и оно не работает.
    Public Sub lb_users_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lb_users.SelectedIndexChanged
            Dim user_id As String = lb_users.SelectedValue.ToString
            MainForm.LoadUserInfo(user_id)
    End Sub
End Class

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question