Click to See Complete Forum and Search --> : InitProperties


October 13th, 1999, 08:57 AM
I set some initial properties (caption and some others) of my control in the IniPropererties event. I open in design mode the form which will contain my control; I put my control in and it has the properties I set before; I change the caption; I open the code of my control and then go back to the form in design mode; my control has lost the caption I changed before!! What can I do?? I don't know how to keep the properties set before, if I don't open the form in run-time mode!! Hope you help me!!

Vlad Chapranov
October 13th, 1999, 04:52 PM
You need to use WriteProperties and ReadProperties. This is an example :

private Sub UserControl_ReadProperties(PropBag as PropertyBag)

m_BackColor = PropBag.ReadProperty("BackColor", m_def_BackColor)
lblMessage.Caption = PropBag.ReadProperty("Caption", "Label1")
m_Caption = PropBag.ReadProperty("Caption", m_def_Caption)
set lblMessage.Font = PropBag.ReadProperty("Font", Ambient.Font)
m_Percent = PropBag.ReadProperty("Percent", m_def_Percent)
End Sub

private Sub UserControl_WriteProperties(PropBag as PropertyBag)

Call PropBag.WriteProperty("BackColor", m_BackColor, m_def_BackColor)
Call PropBag.WriteProperty("Caption", lblMessage.Caption, "Label1")
Call PropBag.WriteProperty("Caption", m_Caption, m_def_Caption)
Call PropBag.WriteProperty("Font", lblMessage.Font, Ambient.Font)
Call PropBag.WriteProperty("Percent", m_Percent, m_def_Percent)
End Sub



Vlad