我發現了propertygrid,它可能很方便進行編輯,或者只是在我的程序中顯示一些自定義安裝數據。但是我需要一些屬性屬性是可變的。
像'readonly'屬性。在vb.net運行時更改屬性屬性
這是我到目前爲止有:
Const myPersonCat As String = "MyPerson"
Const myDesc1 As String = "Firstname is one element"
<CategoryAttribute(myPersonCat), _
DescriptionAttribute(myDesc1), _
[ReadOnly](myBool)> _
Public Property firstname() As String
Get
Return _firstname
End Get
Set(ByVal value As String)
If Not _firstname = value Then save_param("firstname", value, myPersonCat, myDesc1)
_firstname = value
End Set
End Property
Const mydesc2 As String = "but Lastname is second"
<CategoryAttribute(myPersonCat), _
DescriptionAttribute(mydesc2), _
[ReadOnly](myBool)> _
Public Property lastname() As String
Get
Return _lastname
End Get
Set(ByVal value As String)
If Not _lastname = value Then save_param("lastname", value, myPersonCat, myDesc2)
_lastname = value
End Set
End Property
SAVE_PARAM是調用的函數與數據庫的基本數據保存屬性。
所有這些工作都很好。
但現在是一個問題... 在這裏有一些,不是太複雜的方式來設置'myBool'爲只讀屬性與變量,而不是常量,我可以阻止改變一些屬性可靠的情況在程序中。
也許整個類別或單個屬性?
或者,也許這裏存在一些其他方式來獲得類似的功能?
**選中此問題** http://stackoverflow.com/questions/51269/change-attributes-parameter-at-runtime –