Hi Folks,
I have form that contains many containers. And in my code I look for every container and set enabled property for each child control to false. The code works with any container control except winTab.
Please any idea.
Private Sub LockTheControls(ByVal ctl As Control, ByVal Lock As Boolean)
Dim ctlChild As Control For Each ctlChild In ctl.Controls If (TypeOf ctlChild Is UltraDropDownButton) Then ctlChild.Enabled = Lock If (TypeOf ctlChild Is UltraButton) Then ctlChild.Enabled = LockIf (TypeOf ctlChild Is UltraCombo) Then ctlChild.Enabled = Lock If (TypeOf ctlChild Is UltraCalculator) Then ctlChild.Enabled = LockIf (TypeOf ctlChild Is UltraCalculatorDropDown) Then ctlChild.Enabled = Lock If (TypeOf ctlChild Is UltraCheckEditor) Then ctlChild.Enabled = LockIf (TypeOf ctlChild Is UltraColorPicker) Then ctlChild.Enabled = Lock If (TypeOf ctlChild Is UltraComboEditor) Then ctlChild.Enabled = LockIf (TypeOf ctlChild Is UltraCurrencyEditor) Then ctlChild.Enabled = Lock If (TypeOf ctlChild Is UltraDateTimeEditor) Then ctlChild.Enabled = LockIf (TypeOf ctlChild Is UltraFontNameEditor) Then ctlChild.Enabled = Lock If (TypeOf ctlChild Is UltraNumericEditor) Then ctlChild.Enabled = LockIf (TypeOf ctlChild Is UltraCheckEditor) Then ctlChild.Enabled = Lock If (TypeOf ctlChild Is UltraOptionSet) Then ctlChild.Enabled = LockIf (TypeOf ctlChild Is UltraPictureBox) Then ctlChild.Enabled = Lock If (TypeOf ctlChild Is UltraTextEditor) Then ctlChild.Enabled = LockIf (TypeOf ctlChild Is UltraTimeZoneEditor) Then ctlChild.Enabled = Lock If (TypeOf ctlChild Is UltraTrackBar) Then ctlChild.Enabled = LockIf (TypeOf ctlChild Is UltraFormattedTextEditor) Then ctlChild.Enabled = Lock Next
For Each ctlChild In ctl.Controls
If (TypeOf ctlChild Is UltraDropDownButton) Then ctlChild.Enabled = Lock If (TypeOf ctlChild Is UltraButton) Then ctlChild.Enabled = LockIf (TypeOf ctlChild Is UltraCombo) Then ctlChild.Enabled = Lock If (TypeOf ctlChild Is UltraCalculator) Then ctlChild.Enabled = LockIf (TypeOf ctlChild Is UltraCalculatorDropDown) Then ctlChild.Enabled = Lock If (TypeOf ctlChild Is UltraCheckEditor) Then ctlChild.Enabled = LockIf (TypeOf ctlChild Is UltraColorPicker) Then ctlChild.Enabled = Lock If (TypeOf ctlChild Is UltraComboEditor) Then ctlChild.Enabled = LockIf (TypeOf ctlChild Is UltraCurrencyEditor) Then ctlChild.Enabled = Lock If (TypeOf ctlChild Is UltraDateTimeEditor) Then ctlChild.Enabled = LockIf (TypeOf ctlChild Is UltraFontNameEditor) Then ctlChild.Enabled = Lock If (TypeOf ctlChild Is UltraNumericEditor) Then ctlChild.Enabled = LockIf (TypeOf ctlChild Is UltraCheckEditor) Then ctlChild.Enabled = Lock If (TypeOf ctlChild Is UltraOptionSet) Then ctlChild.Enabled = LockIf (TypeOf ctlChild Is UltraPictureBox) Then ctlChild.Enabled = Lock If (TypeOf ctlChild Is UltraTextEditor) Then ctlChild.Enabled = LockIf (TypeOf ctlChild Is UltraTimeZoneEditor) Then ctlChild.Enabled = Lock If (TypeOf ctlChild Is UltraTrackBar) Then ctlChild.Enabled = LockIf (TypeOf ctlChild Is UltraFormattedTextEditor) Then ctlChild.Enabled = Lock
If (TypeOf ctlChild Is UltraButton) Then ctlChild.Enabled = Lock
If (TypeOf ctlChild Is UltraCalculator) Then ctlChild.Enabled = Lock
If (TypeOf ctlChild Is UltraCheckEditor) Then ctlChild.Enabled = Lock
If (TypeOf ctlChild Is UltraComboEditor) Then ctlChild.Enabled = Lock
If (TypeOf ctlChild Is UltraDateTimeEditor) Then ctlChild.Enabled = Lock
If (TypeOf ctlChild Is UltraNumericEditor) Then ctlChild.Enabled = Lock
If (TypeOf ctlChild Is UltraOptionSet) Then ctlChild.Enabled = Lock
If (TypeOf ctlChild Is UltraTextEditor) Then ctlChild.Enabled = Lock
If (TypeOf ctlChild Is UltraTrackBar) Then ctlChild.Enabled = Lock
Next
End Sub
Dim ctl As ControlFor Each ctl In Me.Controls If IsContainerControl(ctl) Then If ctl.HasChildren = True Then LockTheControls(ctl, False) Else LockTheControls(Me, False) End If Next
Dim ctl As Control
If IsContainerControl(ctl) Then If ctl.HasChildren = True Then LockTheControls(ctl, False) Else LockTheControls(Me, False) End If
If IsContainerControl(ctl) Then
If ctl.HasChildren = True Then LockTheControls(ctl, False)
Else
LockTheControls(Me, False)
End If
Public Function IsContainerControl(ByVal ctlControl As Control) As Boolean
Dim bResult As Boolean = False
Dim objDesignerType As Type
objControlType = ctlControl.GetType
For Each objAttribute In objControlType.GetCustomAttributes( _
If TypeOf objAttribute Is System.ComponentModel.DesignerAttribute Then
objDesignerType = System.Type.GetType(objDesignerAttribute.DesignerTypeName)
If GetType(System.Windows.Forms.Design.ParentControlDesigner).IsAssignableFrom(objDesignerType) Then
bResult = True
Exit For
End Function
TraverseForm()
End Class
This is due to the fact that the UltraTabControl also contains other containers. You should recursively call your LockTheControls method when you encounter an UltraTabPageControl within LockTheControls. This should set the correct enabled state of all child controls in the tab control.