首 页 行业资讯 新车 试驾评测 养车用车 车型库

VB 关于自定义控件 设计属性

发布网友 发布时间:2022-04-20 07:35

我来回答

2个回答

热心网友 时间:2022-04-27 15:59

'首先,你的代码应该只有下面的部分(例如):

Public Property Let ItemHeight(ByVal NewHeight As Long)
m_ItemHeight = NewHeight
End Property
Public Property Get ItemHeight () As Long
ItemHeight = m_ItemHeight
End Property
' 上面分别是控件属性的Get和Let属性过程,这只能实现在设计阶段输入这些属性,要想保存这些属性,并且重新加载时加载这些属性值,必须有保存属性和读取属性的代码。你的情况就是上述情况,我初学时也遇到过。
' 需要加以下的代码(供参考):

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)'写属性。将你设置的属性写入属性文件保存
Call PropBag.WriteProperty("ItemHeight", m_ItemHeight) '列表x项高度
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)‘读取属性值
m_ItemHeight = PropBag.ReadProperty("ItemHeight", 28) 'm_ItemHeight) '列表项高度
End Sub
'大功告成

热心网友 时间:2022-04-27 17:17

从新运行以下控件。检查下步骤是否出错

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com