我在自编的控件中,写下了以下属性代码,运行良好,可以在Load事件中对控件的行进行属性读写改变.Public Property Let Rows(RowsGet As Long)
    lngN = RowsGet
End PropertyPublic Property Get Rows() As Long
    Rows = lngN
End Property比如a.rows=5或debug.print a.rows可是,我在VB的IDE的属性界面更改它的值为5时(就是更改控件属性的默认值),保存后总是恢复到0.也就是说不能使用属性界面为控件设默认值.请问大虾原因何在?

解决方案 »

  1.   

    Public Property Let Rows(RowsGet As Long) 
        lngN = RowsGet 
        PropertyChanged "Rows"  '增加这一句
    End Property 
      

  2.   

    Public Property Let Rows(RowsGet As Long)
        lngN = RowsGet
        PropertyChanged "Rows" '刷新
    End PropertyPrivate Sub UserControl_ReadProperties(PropBag As PropertyBag)
        Me.Rows = PropBag.ReadProperty("Rows", 0) '恢复
    End SubPrivate Sub UserControl_WriteProperties(PropBag As PropertyBag)
        PropBag.WriteProperty "Rows", lngN, 0 '保存
    End Sub