Skip to content

Instantly share code, notes, and snippets.

@wolf99
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolf99/c9baef901d2458dddd7c to your computer and use it in GitHub Desktop.
Save wolf99/c9baef901d2458dddd7c to your computer and use it in GitHub Desktop.
Extension to Un-embolden the text of collection of VB.NETcontrols, including any children controls, excepting of a given type T
'Usage: Form1.Controls.UnBold(Of GroupBox) 'Un-emboldens all control.Font perperties, except for GroupBox
Imports System.Runtime.CompilerServices
Module Extensions
<Extension()>
Public Sub UnBold(Of T As Control)(cc As Control.ControlCollection)
For Each c As Control In cc
If Not TypeOf c Is T AndAlso c.GetType.GetProperty("Font") IsNot Nothing Then
Dim RegularFont As New Font(c.Font.FontFamily, c.Font.Size, FontStyle.Regular)
c.Font = RegularFont
ElseIf c.HasChildren Then
UnBold(Of T)(c.Controls)
End If
Next
End Sub
End Module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment