G
Guest
With the help of Cor Ligthert [MVP] in a pryor post I was able to make this
sub:
Public Sub disableControls(ByVal frm As Form)
'this is to create a read only form that has active buttons
Dim x As Long 'used for doing nothing
For Each ctr As Control In frm.Controls
If TypeOf ctr Is ComboBox Then
ctr.Enabled = False
ElseIf TypeOf ctr Is DateTimePicker Then
ctr.Enabled = False
ElseIf TypeOf ctr Is TextBox Then
ctr.Enabled = False
ElseIf TypeOf ctr Is GroupBox Then
ctr.Enabled = False
ElseIf TypeOf ctr Is Label Then
x = x
ElseIf TypeOf ctr Is Button Then
x = x
ElseIf TypeOf ctr Is TabControl Then
For Each tabctr As Control In System.Windows.Forms.TabControl
'???????????????
Next
End If
Next
This works great eccept for the TabControl. I need the TextBoxs, etc in the
TabControl disabled but not the Tabs or Buttons within the TabControl.
I can't seem to find the syntax I need to step through this collection (if
it is a collection). I will probably need the syntax to do the same with a
Group (which I was unable at first pass to do).
Thanks for the help. (A piece of code showing how would be Great!)
Rich
sub:
Public Sub disableControls(ByVal frm As Form)
'this is to create a read only form that has active buttons
Dim x As Long 'used for doing nothing
For Each ctr As Control In frm.Controls
If TypeOf ctr Is ComboBox Then
ctr.Enabled = False
ElseIf TypeOf ctr Is DateTimePicker Then
ctr.Enabled = False
ElseIf TypeOf ctr Is TextBox Then
ctr.Enabled = False
ElseIf TypeOf ctr Is GroupBox Then
ctr.Enabled = False
ElseIf TypeOf ctr Is Label Then
x = x
ElseIf TypeOf ctr Is Button Then
x = x
ElseIf TypeOf ctr Is TabControl Then
For Each tabctr As Control In System.Windows.Forms.TabControl
'???????????????
Next
End If
Next
This works great eccept for the TabControl. I need the TextBoxs, etc in the
TabControl disabled but not the Tabs or Buttons within the TabControl.
I can't seem to find the syntax I need to step through this collection (if
it is a collection). I will probably need the syntax to do the same with a
Group (which I was unable at first pass to do).
Thanks for the help. (A piece of code showing how would be Great!)
Rich