Last active
August 29, 2015 14:27
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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