Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- option explicit
- Class FormWrapper
- Private m_form
- Public Property Let Form(ByRef val)
- m_form = val
- End Property
- Public Property Let ReadOnly(ByVal val)
- SetReadOnly val
- End Property
- Private Sub SetReadOnly(ByVal ReadOnly)
- Dim i
- On Error Resume Next
- For i = 0 To m_form.ControlCount - 1
- Select Case TypeName(m_form.Controls(i))
- ' Controls that have a ReadOnly property
- Case "Edit": m_form.Controls(i).ReadOnly = ReadOnly
- Case "Memo": m_form.Controls(i).ReadOnly = ReadOnly
- Case "AutoCompleteEdit": m_form.Controls(i).ReadOnly = ReadOnly
- Case "DateTimeEdit": m_form.Controls(i).ReadOnly = ReadOnly
- Case "LinkEdit": m_form.Controls(i).ReadOnly = ReadOnly
- Case "ListView": m_form.Controls(i).ReadOnly = ReadOnly
- Case "LookupEdit": m_form.Controls(i).ReadOnly = ReadOnly
- Case "NameEdit": m_form.Controls(i).ReadOnly = ReadOnly
- Case "PickList": m_form.Controls(i).ReadOnly = ReadOnly
- Case "PopupEdit": m_form.Controls(i).ReadOnly = ReadOnly
- Case "RichEdit": m_form.Controls(i).ReadOnly = ReadOnly
- Case "TreeView": m_form.Controls(i).ReadOnly = ReadOnly
- Case "DataGrid": m_form.Controls(i).ReadOnly = ReadOnly
- ' Controls that must be disabled
- ' One thing to note, we actually need to negate the ReadOnly parameter passed
- ' so that the Enabled property is set to False when the form is set to ReadOnly=True
- Case "CheckBox": m_form.Controls(i).Enabled = Not ReadOnly
- Case "ComboBox": m_form.Controls(i).Enabled = Not ReadOnly
- Case "CheckListBox": m_form.Controls(i).Enabled = Not ReadOnly
- Case "DateTimePicker": m_form.Controls(i).Enabled = Not ReadOnly
- Case "Image": m_form.Controls(i).Enabled = Not ReadOnly
- Case "ListBox": m_form.Controls(i).Enabled = Not ReadOnly
- Case "MonthCalendar": m_form.Controls(i).Enabled = Not ReadOnly
- Case "Panel": m_form.Controls(i).Enabled = Not ReadOnly
- Case "ProgressBar": m_form.Controls(i).Enabled = Not ReadOnly
- Case "RadioButton": m_form.Controls(i).Enabled = Not ReadOnly
- Case "RadioGroup": m_form.Controls(i).Enabled = Not ReadOnly
- Case "ScrollBar": m_form.Controls(i).Enabled = Not ReadOnly
- Case "Shape": m_form.Controls(i).Enabled = Not ReadOnly
- Case "Timer": m_form.Controls(i).Enabled = Not ReadOnly
- Case "TrackBar": m_form.Controls(i).Enabled = Not ReadOnly
- Case "UpDown": m_form.Controls(i).Enabled = Not ReadOnly
- ' We are purposely excluding "Button", but if you also want to disable those...
- 'Case "Button": m_form.Controls(i).Enabled = ReadOnly
- End Select
- Next
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement