(With code) How do I change the flatstyle of all buttons of all forms (closed or opened)
Here's my current code:
Dim myAssembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly() Dim types As Type() = myAssembly.GetTypes() For Each myType In types If myType.BaseType.FullName = "System.Windows.Forms.Form" Then Dim frm As New Form Dim formName As String = myType.Name formName = Application.ProductName & "." & formName frm = CType(Activator.CreateInstance(myType), Form) For Each c As Control In frm.Controls If TypeOf c Is Button Then Dim btn As Button = CType(c, Button) btn.FlatStyle = FlatStyle.Flat End If Next End If Next
The problems with my code are:
- It doesn't change the properties of "btn"
- It's messy
So, what's the problem with my code?