Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  2. Dim asm = System.Reflection.Assembly.GetExecutingAssembly
  3. Dim myTypes As Type() = asm.GetTypes()
  4. Dim frm As Form
  5.  
  6.  
  7. For Each t As Type In myTypes
  8. If t.IsSubclassOf(GetType(System.Windows.Forms.Form)) AndAlso TextBox1.Text = t.Name Then
  9. frm = CType(Activator.CreateInstance(t), Form)
  10. frm.Hide()
  11.  
  12. Dim thisButtonName As String = TextBox3.Text ' This is the name of the button I'm looking for
  13. Dim thisButtonName2 As String = TextBox2.Text ' this is the new tag name for that button
  14. ' Loop all controls in this form
  15. For Each ctrl As Control In Controls
  16. ' Is this control a button
  17. If TypeOf (ctrl) Is Button Then
  18. ' Is this the correct button
  19. If CType(ctrl, Button).Name = thisButtonName Then
  20. CType(ctrl, Button).Tag = thisButtonName2
  21. End If
  22. End If
  23. Next
  24. End If
  25. Next
  26.  
  27. TreeView1.Nodes.Clear()
  28.  
  29. For Each formprop In My.Forms.GetType.GetProperties
  30. Dim node = Me.TreeView1.Nodes.Add(formprop.Name)
  31. Dim form As Form = CType(formprop.GetValue(My.Forms, Nothing), Form)
  32. ControlsTree(node, form.Controls)
  33. Next
  34. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement