Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide Methods In User Control 1

Status
Not open for further replies.

txmed

Programmer
Mar 23, 2006
65
US
Hello. I'm working on a user control that inherits a Timer control. I written customer properties and methods for the Timer.

My problem is that now, when I create a variable of this user control, the intellisense show all of the properties and methods for the user control, including events like AutoSize, BackColor, and Size. I was wondering if there's a way I can hide every property/event from the intellisense except for my customer events?

Any help will be greatly appreciated!

(txmed)
 
Rather than inherit from the Timer Control, you could inherit from Component.

The following does nothing - its a new User Control, but I've changed the Inherits statement and simply added a Timer (from the Components tab (not the Windows tab).

This should ensure than only Properties, Methods and Events that you publish will be available.

Code:
Public Class UserControl1
  Inherits System.ComponentModel.Component

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'UserControl1 overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
  Private WithEvents Timer1 As System.Timers.Timer
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.Timer1 = New System.Timers.Timer
    CType(Me.Timer1, System.ComponentModel.ISupportInitialize).BeginInit()
    '
    'Timer1
    '
    Me.Timer1.Enabled = True
    CType(Me.Timer1, System.ComponentModel.ISupportInitialize).EndInit()

  End Sub

#End Region


End Class

Hope this helps.

[vampire][bat]
 
Yep E&F's solution is the most simple. However you can hide them by using the attributes but then you will have to hide each and every propertie there is

I can't really remember wich attribute it was (not something I do every day. but I think it is somewhere in componentmodel.

so

Code:
<ComponentModel.Browsable(False)>public override property backcolor as color
...

Christiaan Baes
Belgium

"My new site" - Me
 
Thanks E&F and Chrissie. I'm going to try E&F's recommendation first.

(txmed)
 
Thanks E&F, your solution worked great. Have a star!

(txmed)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top