Form refresh help

DLK

Member
Joined
Oct 21, 2005
Messages
6
Programming Experience
3-5
Hi, I'm new to vb.net and have searched everywhere and can only find one answer that doesn't work.

I have a form with dynamically created labels and buttons. When I click a button, it calls a sub that performs an action and I want to update the labels text. Everywhere I look says to use Refresh() but it ain't working.
Can anyone shed some light on how to do this?
 
first off welcome to the forums :)

when you create the label's and button's you shouldnt need to use any refresh, but for them to be displayed you do gotta remember to add them to the form's collection:

Me.Controls.Add(your button or label name here)

and you can change the text property like you would any other button or label that you added through the designer
 
Thanks for the replies.
JuggaloBrotha, thats how I did do it, the problem is when I click one of the created buttons, it performs an action and I'd like the text on one of the labels changed. Using Me.Refresh() doesn't work. What I think I need is a way of reloading the form.
 
the newly created button, did you put in a handler for it like
Addhandler <new button> AddressOf sub for button click
 
You want to change the Label text?

This is probably way to simple because I don't fully understand the problem. Could it be as easy as this?

VB.NET:
    Private Sub startButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles startButton.Click
        Label1.Text = "new text"
    End Sub
 
yes you're right, that was too simple. Heres what I'm doing. I'm creating a form with a listing of selected services with stop start buttons and the current status of the service. This list is generated dynamically, When I click on the stop button, the service stops and I want to update the status to reflect the new status but nothing is working.
 
doesn't work! How do I access the name of the label from another sub ie: the stop service sub and also when the labels are dynamically created.
 
Hey DLK,

You could, when you create the labels, place them in an arraylist or Collection declared at the top of your form and access them from there. Still don't completely understand the issue though.
 
Back
Top