CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: InitProperties

  1. #1
    Guest

    InitProperties

    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!!


  2. #2
    Join Date
    Apr 1999
    Location
    Brooklyn, NY USA
    Posts
    171

    Re: InitProperties

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured