G
Geoff Edwards
I know it might be a bit OTT, but many users of my templates get upset
when they find a space in a dialog which is both white but not
enabled.
I have written this code to check whether a control is enabled and
turn the white bit of the relevant controls (textbox, combobox,
listbox etc) grey if it is not:
Public Sub SetBackgroundColours(ctrl As Control)
With ctrl
If .Enabled Then
.BackColor = &H80000005
Else
.BackColor = &H8000000F
End If
End With
End Sub
This works perfectly well, but I haven't found a way of checking the
controls on a form to see if they are of a type of control which I
want to change. I do want to change the backgrounds of a textbox,
listbox or combobox to grey if it is disabled, but I don't want to
change the background of an entire frame to white if it enabled!
Hence
For Each ctrl In Me.Controls
SetBackgroundColours ctrl
Next
doesn't work.
At the moment, I am setting the tag of each "colourable" control to
(wait for it ) "Colourable" and using:
Dim ctrl As Control
For Each ctrl In Me.Controls
If ctrl.Tag = "Colourable" Then SetBackgroundColours ctrl
Next
but there must be a better method which will, presumably, involved
testing each control for its actual control type. How do I do that?
Or is there a better way of doing this altogether?
TIA
Geoff Edwards
Leeds, UK
e-mail: (e-mail address removed)
(replace the stopspambot bit with some
version of my name)
when they find a space in a dialog which is both white but not
enabled.
I have written this code to check whether a control is enabled and
turn the white bit of the relevant controls (textbox, combobox,
listbox etc) grey if it is not:
Public Sub SetBackgroundColours(ctrl As Control)
With ctrl
If .Enabled Then
.BackColor = &H80000005
Else
.BackColor = &H8000000F
End If
End With
End Sub
This works perfectly well, but I haven't found a way of checking the
controls on a form to see if they are of a type of control which I
want to change. I do want to change the backgrounds of a textbox,
listbox or combobox to grey if it is disabled, but I don't want to
change the background of an entire frame to white if it enabled!
Hence
For Each ctrl In Me.Controls
SetBackgroundColours ctrl
Next
doesn't work.
At the moment, I am setting the tag of each "colourable" control to
(wait for it ) "Colourable" and using:
Dim ctrl As Control
For Each ctrl In Me.Controls
If ctrl.Tag = "Colourable" Then SetBackgroundColours ctrl
Next
but there must be a better method which will, presumably, involved
testing each control for its actual control type. How do I do that?
Or is there a better way of doing this altogether?
TIA
Geoff Edwards
Leeds, UK
e-mail: (e-mail address removed)
(replace the stopspambot bit with some
version of my name)