Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27069

[RESOLVED] PropertyGrid - Show certain properties

$
0
0
I'm creating a pretty neat program which implements the PropertyGrid control. Whenever I'm creating my own classes, using the PropertyGrid is fine because the properties it shows are the properties that I wrote. But whenever I inherit a control, it display's my custom properties as well as all the properties of that control that I inherited. Is there anyway around this where I can just display properties that I set up in my class? Ie -
Code:

Option Strict On
Option Explicit On
Public Class MenuItem
    Inherits Button

    Public Property Border As Boolean = True
    Public Property BorderColor As Color = Color.Black
    Public Property BorderThickness As Integer = 1
    Public Property MouseDownColor As Color = Color.White
    Public Property MouseHoverColor As Color = Color.White
    Public Overrides Property Text As String
        Get
            Return MyBase.Text
        End Get
        Set(value As String)
            MyBase.Text = value
        End Set
    End Property

End Class

That would only display:
  • Border
  • BordderColor
  • BorderThickness
  • MouseDownColor
  • MouseHoverColor
  • Text



Edit - I wound up hiding the properties like this:
Code:

    <Browsable(False)> Public Overrides Property AllowDrop As Boolean
        Get
            Return MyBase.AllowDrop
        End Get
        Set(value As Boolean)
            MyBase.AllowDrop = value
        End Set
    End Property

Now I'm facing the issue that properties that cannot be overridden such as FlatStyle, UseMnemonic, UseWaitCursor, etc. still get shown.

Viewing all articles
Browse latest Browse all 27069

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>