Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8021101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:52:39+00:00 2026-06-04T21:52:39+00:00

I have a custom version of a label control (built using a user control).

  • 0

I have a custom version of a label control (built using a user control). While working in the designer, I want to intercept the setting of the Name property (in the properties panel) and use it to generate the Text property. That is, if I enter “lblFirstName” into the Name property of the properties panel I want to immediately see that the Text property is set to “First Name”.

Parsing the Name property is not the issue; I can do that.

I have tried to overload/shadow the Name property (since “Overrides” is not allowed) to essentially add this “aspect” to our custom label control but it doesn’t seem to hit the Shadowed method at design time. It does hit the Shadowed method at run time if manipulated via code.

The point is to avoid double the work as the label text and the label name are essentially the same. The only difference is one is formatted to be human friendly and the other machine friendly.

<System.ComponentModel.Browsable(True),
 System.ComponentModel.ParenthesizePropertyName(),
 System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Visible)>
Public Shadows Property Name As String
    Get
        Return MyBase.Name
    End Get
    Set(value As String)
        MyBase.Name = value
        If Me.DesignMode Then
            Me.Text = Humanize(value)
        End If
        Me.Invalidate()
    End Set
End Property

This may be a matter of picking the right attributes. I’m not sure.

Conversely, if it’s an easier alternative, we could allow setting the Text property to set the Name property. I doubt this would be easier since it should also reflect the new name in the Designer.vb code, not just in the label’s Name property itself.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:52:42+00:00Added an answer on June 4, 2026 at 9:52 pm

    You can do this with some extra design time elements. The IComponentChangeService is your hook to design time change events.

    Imports System.ComponentModel.Design
    Imports System.ComponentModel
    
    Class RenameLabel
         Inherits System.Windows.Forms.Label
         Private WithEvents _compChServ As IComponentChangeService
    
         Public Overrides Property Site() As ISite
             Get
                Return MyBase.Site
             End Get
             Set(ByVal Value As ISite)
                If _compChServ IsNot Nothing Then _
                   RemoveHandler _compChServ.ComponentRename, AddressOf nameChanged
    
                MyBase.Site = Value
    
                _compChServ = CType(GetService(GetType(IComponentChangeService)), _
                              IComponentChangeService)
    
                If _compChServ IsNot Nothing Then _
                   AddHandler _compChServ.ComponentRename, AddressOf nameChanged
             End Set
        End Property
    
        Private Sub nameChanged(ByVal sender As Object, ByVal e As _
                                ComponentRenameEventArgs)
             'Add your change code here
             Me.Text = Me.Name
        End Sub
    
        Protected Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If _compChServ IsNot Nothing Then _
                   RemoveHandler _compChServ.ComponentRename, AddressOf nameChanged
            End If
            MyBase.Dispose(disposing)
        End Sub
    
    End Class
    

    MSDN – IComponentChangeService

    MSDN – ISite

    EDIT : added disposing code!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have my custom folder in my SugarCRM 6.2 sandbox under git version control.
Hadoop Version: 0.20.2 (On Amazon EMR) Problem: I have a custom key that i
I'm trying to make a custom infowindow. Version = 2. I have added my
I have custom control written in Java. For the sake of simplicity lets assume
I have custom Joomla(v1.5) component and currently working with component's router. The problem is
I would like to create a custom version of the sortable widget. I have
I have created a custom labeller for CC.Net which is working almost perfectly, however
Actually I have created a custom ListView . I want to add items to
After I have changed my dll containing my custom control I am getting warnings
I have a HorizontalList control that uses a custom ItemRenderer to represent each item

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.