StrataFrame Forum

Public Form property not shown in Property editor

http://forum.strataframe.net/Topic19559.aspx

By Greg McGuffey - 9/19/2008

I have a couple of properties, both of type Color, that I added to a form. They are public properties, I've set up a Category() and Description() and added ShouldSerialize/Reset methods for them. However, I can't get them to show up in the property editor (grid). I would have sworn that there wasn't anything special to get this to work, but I'm baffled. Any ideas what I could be doing wrong?



Here's the code:



Private _passingBackColor As Color = Color.LightGreen



''' <summary>

''' Define the color used to highlight items that have passing

''' scores.

''' </summary>

<Category("RAMS: Score Formatting") _

, Description("Define the color used to highlight passing scores in the list.")> _

Public Property PassingBackColor() As Color

Get

Return _passingBackColor

End Get

Set(ByVal value As Color)

_passingBackColor = value

End Set

End Property



Private _failingBackColor As Color = Color.LightPink



''' <summary>

''' Define the color used to highlight items that have failing

''' scores.

''' </summary>

<Category("RAMS: Score Formatting") _

, Description("Define the color used to highlight failing scores in the list.")> _

Public Property FailingBackColor() As Color

Get

Return _failingBackColor

End Get

Set(ByVal value As Color)

_failingBackColor = value

End Set

End Property



''' <summary>

''' Return if the designer should serialize the PassingBackColor

''' property.

''' </summary>

''' <returns>True if property needs to be serialized to the designer</returns>

''' <remarks></remarks>

Public Function ShouldSerializePassingBackColor() As Boolean

Return _passingBackColor <> Color.LightGreen

End Function



''' <summary>

''' Reset the PassingBackColor to its default value and remove serialization

''' the property from the designer.

''' </summary>

''' <remarks></remarks>

Public Sub ResetPassingBackColor()

_passingBackColor = Color.LightGreen

End Sub



''' <summary>

''' Return if the designer should serialize the FailingBackColor

''' property.

''' </summary>

''' <returns>True if property needs to be serialized to the designer</returns>

''' <remarks></remarks>

Public Function ShouldSerializeFailingBackColor() As Boolean

Return _failingBackColor = Color.LightPink

End Function



''' <summary>

''' Reset the FailingBackColor to its default value and remove serialization

''' the property from the designer.

''' </summary>

''' <remarks></remarks>

Public Sub ResetFailingBackColor()

_failingBackColor = Color.LightPink

End Sub
By Ivan George Borges - 9/20/2008

Hey Greg.

Not sure this is the cause, but I define the DescriptionAttribute, not the Description, as you are coding over there:

''' <summary>
''' Define the color used to highlight items that have passing
''' scores.
''' </summary>
<Category("RAMS: Score Formatting") _
  , DescriptionAttribute("Define the color used to highlight passing scores in the list.")> _
Public Property PassingBackColor() As Color
    Get
        Return _passingBackColor
    End Get
    Set(ByVal value As Color)
        _passingBackColor = value
    End Set
End Property

By Keith Chisarik - 9/20/2008

Here is what works for me.

    <Category("Airbase: Custom Settings")> _
    <Description("When set to False, form data hotkeys will be disabled.")> _
    <DefaultValue(True)> _
    Public Property UseAppHotKeys() As Boolean
        Get
            Return Me.p_UseAppHotKeys
        End Get
        Set(ByVal value As Boolean)
            Me.p_UseAppHotKeys = value
        End Set
    End Property

By Trent L. Taylor - 9/22/2008

It looks correct.  If you are adding the properties to a class and then going into the designer of the same class, the properties will not show up.  However, if you drop the control on a different designer (i.e. drop a textbox on a form) or subclass the class, they will then show up on the inherited class within the designer.  Past that, the only other reason that I could think of is if the class in question is private or the heirarchy above these properties is hiding them due to their limited declaration.  Past that, I don't see anything blaring at me.
By Greg McGuffey - 9/22/2008

OK, I think Trent has the answer. I didn't know that properties of a class didn't show up on that same class (in this case a form). I had added the properties to a form and then looked for those properties on that same form in the designer. If I understand you correctly, they would only show up for inherited forms or in the case of components or controls when dropped onto another container control. Is that correct?
By Trent L. Taylor - 9/22/2008

You got it Wink
By Greg McGuffey - 9/22/2008

Thanks! Mystery solved! w00t