Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. option explicit
  2.  
  3. Class FormWrapper
  4.  
  5. Private m_form
  6.  
  7. Public Property Let Form(ByRef val)
  8. m_form = val
  9. End Property
  10.  
  11. Public Property Let ReadOnly(ByVal val)
  12. SetReadOnly val
  13. End Property
  14.  
  15. Private Sub SetReadOnly(ByVal ReadOnly)
  16. Dim i
  17.  
  18. On Error Resume Next
  19.  
  20. For i = 0 To m_form.ControlCount - 1
  21. Select Case TypeName(m_form.Controls(i))
  22. ' Controls that have a ReadOnly property
  23. Case "Edit": m_form.Controls(i).ReadOnly = ReadOnly
  24. Case "Memo": m_form.Controls(i).ReadOnly = ReadOnly
  25. Case "AutoCompleteEdit": m_form.Controls(i).ReadOnly = ReadOnly
  26. Case "DateTimeEdit": m_form.Controls(i).ReadOnly = ReadOnly
  27. Case "LinkEdit": m_form.Controls(i).ReadOnly = ReadOnly
  28. Case "ListView": m_form.Controls(i).ReadOnly = ReadOnly
  29. Case "LookupEdit": m_form.Controls(i).ReadOnly = ReadOnly
  30. Case "NameEdit": m_form.Controls(i).ReadOnly = ReadOnly
  31. Case "PickList": m_form.Controls(i).ReadOnly = ReadOnly
  32. Case "PopupEdit": m_form.Controls(i).ReadOnly = ReadOnly
  33. Case "RichEdit": m_form.Controls(i).ReadOnly = ReadOnly
  34. Case "TreeView": m_form.Controls(i).ReadOnly = ReadOnly
  35. Case "DataGrid": m_form.Controls(i).ReadOnly = ReadOnly
  36.  
  37. ' Controls that must be disabled
  38. ' One thing to note, we actually need to negate the ReadOnly parameter passed
  39. ' so that the Enabled property is set to False when the form is set to ReadOnly=True
  40. Case "CheckBox": m_form.Controls(i).Enabled = Not ReadOnly
  41. Case "ComboBox": m_form.Controls(i).Enabled = Not ReadOnly
  42. Case "CheckListBox": m_form.Controls(i).Enabled = Not ReadOnly
  43. Case "DateTimePicker": m_form.Controls(i).Enabled = Not ReadOnly
  44. Case "Image": m_form.Controls(i).Enabled = Not ReadOnly
  45. Case "ListBox": m_form.Controls(i).Enabled = Not ReadOnly
  46. Case "MonthCalendar": m_form.Controls(i).Enabled = Not ReadOnly
  47. Case "Panel": m_form.Controls(i).Enabled = Not ReadOnly
  48. Case "ProgressBar": m_form.Controls(i).Enabled = Not ReadOnly
  49. Case "RadioButton": m_form.Controls(i).Enabled = Not ReadOnly
  50. Case "RadioGroup": m_form.Controls(i).Enabled = Not ReadOnly
  51. Case "ScrollBar": m_form.Controls(i).Enabled = Not ReadOnly
  52. Case "Shape": m_form.Controls(i).Enabled = Not ReadOnly
  53. Case "Timer": m_form.Controls(i).Enabled = Not ReadOnly
  54. Case "TrackBar": m_form.Controls(i).Enabled = Not ReadOnly
  55. Case "UpDown": m_form.Controls(i).Enabled = Not ReadOnly
  56.  
  57. ' We are purposely excluding "Button", but if you also want to disable those...
  58. 'Case "Button": m_form.Controls(i).Enabled = ReadOnly
  59. End Select
  60. Next
  61. End Sub
  62.  
  63. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement