Question List forms and update all labels

Johnnyontheweb

New member
Joined
Jan 13, 2012
Messages
1
Location
Trieste, Italy, Italy
Programming Experience
1-3
Hello everyone,
I have a problem in changing properties in controls and forms.
I'm trying to write a sub that changes all labels in controls and menus in my application.
I post the code below, with the following code I can correctly get all the labels present, but cannot change them (see for example just the first instruction t.Text = "Information" that has to be applied if exist a form named "info". The problem is that nothing happens in the form named "info", the title remains the same!).
Why?
any help appreciated
many thanks


VB.NET:
Public Sub str_changer()

        Dim formsl As New List(Of Form)()
        Dim formType As Type = Type.GetType("System.Windows.Forms.Form")

        For Each ti As Type In Me.GetType().Assembly.GetTypes()
            If UCase(ti.BaseType.ToString) = "SYSTEM.WINDOWS.FORMS.FORM" Then

                formsl.Add(CType(Activator.CreateInstance(ti), Form))

                Dim t As Form = CObj(ti)
                ' form name
                If t.Name = "main" Then ' main form title
                    t.Text = "Information"
                End If

                ' all controls
                Dim ctrl As Control

                For Each ctrl In t.Controls
                    If TypeOf ctrl Is Button Then
                        If ctrl.Text = "Calculate" Then
                            ctrl.Text = "Calcola"
                        End If
                    End If
          
                Next
                't.Refresh()

           End If
        Next

    End Sub
 
Last edited:
Back
Top