Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
80
can't reach controls in winTab
posted

 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.

 

Public
Class Form2

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 = Lock

If (TypeOf ctlChild Is UltraCombo) Then ctlChild.Enabled = Lock

If (TypeOf ctlChild Is UltraCalculator) Then ctlChild.Enabled = Lock

If (TypeOf ctlChild Is UltraCalculatorDropDown) Then ctlChild.Enabled = Lock

If (TypeOf ctlChild Is UltraCheckEditor) Then ctlChild.Enabled = Lock

If (TypeOf ctlChild Is UltraColorPicker) Then ctlChild.Enabled = Lock

If (TypeOf ctlChild Is UltraComboEditor) Then ctlChild.Enabled = Lock

If (TypeOf ctlChild Is UltraCurrencyEditor) Then ctlChild.Enabled = Lock

If (TypeOf ctlChild Is UltraDateTimeEditor) Then ctlChild.Enabled = Lock

If (TypeOf ctlChild Is UltraFontNameEditor) Then ctlChild.Enabled = Lock

If (TypeOf ctlChild Is UltraNumericEditor) Then ctlChild.Enabled = Lock

If (TypeOf ctlChild Is UltraCheckEditor) Then ctlChild.Enabled = Lock

If (TypeOf ctlChild Is UltraOptionSet) Then ctlChild.Enabled = Lock

If (TypeOf ctlChild Is UltraPictureBox) Then ctlChild.Enabled = Lock

If (TypeOf ctlChild Is UltraTextEditor) Then ctlChild.Enabled = Lock

If (TypeOf ctlChild Is UltraTimeZoneEditor) Then ctlChild.Enabled = Lock

If (TypeOf ctlChild Is UltraTrackBar) Then ctlChild.Enabled = Lock

If (TypeOf ctlChild Is UltraFormattedTextEditor) Then ctlChild.Enabled = Lock

Next

End Sub

Private Sub TraverseForm()

Dim ctl As Control

For Each ctl In Me.Controls

If IsContainerControl(ctl) Then

If ctl.HasChildren = True Then LockTheControls(ctl, False)

Else

LockTheControls(Me, False)

End If

Next

End Sub

Public Function IsContainerControl(ByVal ctlControl As Control) As Boolean

Dim bResult As Boolean = False

Dim objControlType As Type

Dim objDesignerType As Type

Dim objAttribute As AttributeDim objDesignerAttribute As System.ComponentModel.DesignerAttribute

objControlType = ctlControl.GetType

For Each objAttribute In objControlType.GetCustomAttributes( _

GetType(System.ComponentModel.DesignerAttribute), False)

If TypeOf objAttribute Is System.ComponentModel.DesignerAttribute Then

objDesignerAttribute = CType(objAttribute, System.ComponentModel.DesignerAttribute)

objDesignerType = System.Type.GetType(objDesignerAttribute.DesignerTypeName)

If GetType(System.Windows.Forms.Design.ParentControlDesigner).IsAssignableFrom(objDesignerType) Then

bResult = True

Exit For

End If

End If

Next

Return bResult

End Function

Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

TraverseForm()

End Sub

End Class

Parents
No Data
Reply
  • 44743
    Verified Answer
    posted

    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.

Children
No Data