Question Custom control Design-Time Features. Label with control name at design time.

DennisHarding

Member
Joined
Oct 25, 2009
Messages
11
Location
Tell City, Indiana
Programming Experience
10+
Custom control: I want a (child) label text property to be the same as the (parent) control name property during design time. I need the label text to change if I change the parent name in design time. I can do it at run time but am getting lost in design time. All the examples I have found for design time seem too complicated for me to follow. I guess I just need a simpler example. Thanks a million in advance.
 
RE, JohnH

Thanks JohnH. I'll give it a try latter today. A little more background for everyone. Cusom control w/ menustrip w/ selection for Properties Dialog w/PropertiesGrid (for runtime of custom properties). This all works fine. Even tried shadowing the Name for design time to add an event and handler, found i didnt realy need the event and handler, just set the Label with the shadowed name property. Problem is when adding a lot of these custom controls at design time was hassel putting an extra Label on the form just for design time to help keep up with all the controls. Renaming each Designtime label when renaming the control and having the same label in run time already working.The serilization keeps the new control name so no problems there either....Hope this wasn't too long winded. I'll give an update tonight.
 
Update

Well, thought It was all good...Works...uh sorta...lol...the label changes at design time now. but so do any other instances on the same control put on the form...so if I change the name of any of the custom controls all of their labels text change to the same thing...At least it is a simpler example and I think I am beginning to understand how it works better...I think I'll try to use a variable for the label's name with the control name in it, also think it might need some error control somewhere.
 
The sample was very single purpose... the IComponentChangeService is notifying all components changes, e.Component in ComponentRename event will tell you which one is the current.
 
Excellent, Excellent, Excellent,

Wow...that got it...took me a little bit to see where you were talkin about. (after a good movie on the ol ladys bday...lol)
I commented out the uc.tbtext = e.NewName & changed it to e.Component.tbtext = e.NewName.
VB.NET:
    Private Sub iccs_ComponentRename(ByVal sender As Object, ByVal e As System.ComponentModel.Design.ComponentRenameEventArgs) Handles iccs.ComponentRename 'Had to add System.ComponentModel. system said ambigous
        'uc.tbtext = e.NewName
        e.Component.tbtext = e.NewName
    End Sub
..Works excellent, even saved when shut down and reopened...This is excellent..only one more thing. I knew there would be someplace to learn the designer part better. All the other examples I have found are just too many trees in the forest to learn it for me. This has realy helped me, thanks a million. Could you point me in a good direction to learn more about the designers in smaller chunks...lol?
 
Could you point me in a good direction to learn more about the designers in smaller chunks...lol?
Not really, I use MSDN library (locally installed) then anything I can find on web for topics MSDN doesn't explain well enough. Extending Design-Time Support
 
Learning more

VB.NET:
find on web for topics MSDN doesn't explain well enough
I agree, MSDN doesn't explain well enough and most articles explain too much.
Anyway, I think you answered this one perfectly. Thanks again.
 
Back
Top