Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have a question regarding a design-time problem.
In VB.net 2010 I have a custom control with a set of custom properties which are shown in the IDE propertygrid, on their own propertytab.

Does anyone know how I can make the IDE show this custom propertytab by default, each time I click the custom usercontrol on the form.
Now VS always switches to the first propertytab in the propertygrid. Here are the properties I don't need and actually don't want the developer being able to access.

An alternative solution might be:
Is there a way to make the standard propertytabs invisible, so only my custom propertytab is shown.

I know about the browsable attribuut, but thats not what I mean, because it concerns individual properties. I am referring to the complete property Tab.


I used the following code:

VB
<propertytab(gettype(ptactivetextbox),propertytabscope.component)> _
Public Class ActiveTextbox
    Inherits System.Windows.Forms.UserControl
    etc....
End Class


Public Class PtActiveTextbox
    Inherits PropertiesTab

    Public Overrides Function CanExtend(ByVal extendee As Object) As Boolean
        Return TypeOf extendee Is ActiveTextbox
    End Function

    Public Overrides Function GetProperties(ByVal context As ITypeDescriptorContext, _
                ByVal component As Object, ByVal attrs As Attribute()) As PropertyDescriptorCollection
        Return TypeDescriptor.GetProperties(component, _
            New Attribute() {New BrowsableAttribute(False), New PtActiveTextboxDisplayAttribute(True)})
    End Function

    Public Overrides ReadOnly Property TabName() As String
        Get
            Return "ActiveTextbox"
        End Get
    End Property

End Class

<attributeusage(attributetargets.property)> _
Public Class PtActiveTextboxDisplayAttribute
    Inherits Attribute

    Private _display As Boolean

    Public Sub New(ByVal display As Boolean)
        Me.Display = display
    End Sub

    Public Property Display() As Boolean
        Get
            Return Me._display
        End Get
        Set(ByVal value As Boolean)
            Me._display = value
        End Set
    End Property

End Class



Thanks in advance.
Posted
Updated 19-Feb-12 0:30am
v2

1 solution

Yes, you can make properties invisible: there is a tip here that explains it. Hiding inherited properties[^]
It's in C#, but it should work for VB too with a small change to the syntax:
C#
[Browsable(false),
EditorBrowsable(EditorBrowsableState.Never)]
public new bool AutoScroll { get; set; }
becomes:
VB
<Browsable(False), EditorBrowsable(EditorBrowsableState.Never)> _
Public Shadows Property AutoScroll() As Boolean
    Get
        Return m_AutoScroll
    End Get
    Set
        m_AutoScroll = Value
    End Set
End Property
Private Shadows m_AutoScroll As Boolean
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900