' I simply created this module for people who wanted some easy functions that return True/False to determine if a particular control was a particular type or of a group..
' You can add more to the module if you want (as not all controls were entered in)
' You can add more to the module if you want (as not all controls were entered in)
Code:
Module _Control_Module
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' These are boolean functions that determine if the control is of a particular type...
Public Function GetIsButton(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.Button" Then
bBtn = True
End If
Return bBtn
End Function
Public Function GetIsTextBox(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.TextBox" Then
bBtn = True
End If
Return bBtn
End Function
Public Function GetIsLabel(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.Label" Then
bBtn = True
End If
Return bBtn
End Function
Public Function GetIsNumericUpAndDownBox(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.NumericUpDown" Then
bBtn = True
End If
Return bBtn
End Function
Public Function GetIsCheckBox(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.CheckBox" Then
bBtn = True
End If
Return bBtn
End Function
Public Function GetIsRadioButton(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.RadioButton" Then
bBtn = True
End If
Return bBtn
End Function
Public Function GetIsComboBox(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.ComboBox" Then
bBtn = True
End If
Return bBtn
End Function
Public Function GetIsListBox(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.ListBox" Then
bBtn = True
End If
Return bBtn
End Function
Public Function GetIsMaskedTextBox(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.MaskedTextBox" Then
bBtn = True
End If
Return bBtn
End Function
Public Function GetIsDateTimePicker(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.DateTimePicker" Then
bBtn = True
End If
Return bBtn
End Function
Public Function GetIsRichTextBox(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.RichTextBox" Then
bBtn = True
End If
Return bBtn
End Function
Public Function GetIsCheckedListBox(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.CheckedListBox" Then
bBtn = True
End If
Return bBtn
End Function
Public Function GetIsLinkLabel(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.LinkLabel" Then
bBtn = True
End If
Return bBtn
End Function
Public Function GetIsPictureBox(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.PictureBox" Then
bBtn = True
End If
Return bBtn
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Tell us if it's a Container
Public Function GetIsContainer(ByVal oControl As Control) As Boolean
Dim bContainer As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.Panel" Then
bContainer = True
ElseIf oControl.GetType.ToString = "System.Windows.Forms.FlowLayoutPanel" Then
bContainer = True
ElseIf oControl.GetType.ToString = "System.Windows.Forms.SplitContainer" Then
bContainer = True
ElseIf oControl.GetType.ToString = "System.Windows.Forms.GroupBox" Then
bContainer = True
ElseIf oControl.GetType.ToString = "System.Windows.Forms.TabControl" Then
bContainer = True
ElseIf oControl.GetType.ToString = "System.Windows.Forms.TableLayoutPanel" Then
bContainer = True
End If
Return bContainer
End Function
' To identify individual containers...
Public Function GetIsPanel(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.Panel" Then
bBtn = True
End If
Return bBtn
End Function
Public Function GetIsFlowLayoutPanel(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.FlowLayoutPanel" Then
bBtn = True
End If
Return bBtn
End Function
Public Function GetIsSplitContainer(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.SplitContainer" Then
bBtn = True
End If
Return bBtn
End Function
Public Function GetIsGroupBox(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.GroupBox" Then
bBtn = True
End If
Return bBtn
End Function
Public Function GetIsTabControl(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.TabControl" Then
bBtn = True
End If
Return bBtn
End Function
Public Function GetIsTableLayoutPanel(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.TableLayoutPanel" Then
bBtn = True
End If
Return bBtn
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Tell us if it's a Menu ...
Public Function GetIsMenu(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.ContextMenuStrip" Then
bBtn = True
ElseIf oControl.GetType.ToString = "System.Windows.Forms.MenuStrip" Then
bBtn = True
ElseIf oControl.GetType.ToString = "System.Windows.Forms.ToolStrip" Then
bBtn = True
ElseIf oControl.GetType.ToString = "System.Windows.Forms.ToolStripContainer" Then
bBtn = True
ElseIf oControl.GetType.ToString = "System.Windows.Forms.StatusStrip" Then
bBtn = True
End If
Return bBtn
End Function
' Determine if it's THIS Menu Type...
Public Function GetIsContextMenuStrip(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.ContextMenuStrip" Then
bBtn = True
End If
Return bBtn
End Function
Public Function GetIsMenuStrip(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.MenuStrip" Then
bBtn = True
End If
Return bBtn
End Function
Public Function GetIsStatusStrip(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.StatusStrip" Then
bBtn = True
End If
Return bBtn
End Function
Public Function GetIsToolStrip(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.ToolStrip" Then
bBtn = True
End If
Return bBtn
End Function
Public Function GetIsToolStripContainer(ByVal oControl As Control) As Boolean
Dim bBtn As Boolean = False
If oControl.GetType.ToString = "System.Windows.Forms.ToolStripContainer" Then
bBtn = True
End If
Return bBtn
End Function
End Module