.NET Forum / Windows Forms / Design Time / December 2005
Getting the name of a control
|
|
Thread rating:  |
Mario Vázquez - 27 Dec 2005 07:48 GMT Hello,
I'm writing a component (inherited from Control) which is a graphic line optionaly attached to a caption text (Caption property). I would like to assign to the Caption property the name of the control, but, when I have to do this? In the constructor the control does'nt has name yet. I've tried to do it handling the HandleCreated event, but then I've found that even if the user changes the Caption property, always it's set to its name.
Any help?
Thanks, Mario Vazquez
Montezuma - 27 Dec 2005 09:28 GMT Ciao Mario, you could override the Name property of your control, and in the set group of statement, you could change the Caption.
Have fun. Montezuma
Mario Vázquez ha scritto:
> Hello, > [quoted text clipped - 10 lines] > Thanks, > Mario Vazquez Mario Vázquez - 27 Dec 2005 10:15 GMT Ok, it's a good idea, I'll try.
Thank you
Mario
> Ciao Mario, > you could override the Name property of your control, and in the set group [quoted text clipped - 18 lines] >> Thanks, >> Mario Vazquez Mario Vázquez - 28 Dec 2005 07:44 GMT Uh uh, the property Name it's not allowed to be overrided... what to do?
> Ciao Mario, > you could override the Name property of your control, and in the set group [quoted text clipped - 18 lines] >> Thanks, >> Mario Vazquez Montezuma - 28 Dec 2005 13:58 GMT Ah, ok. My question is: who gives the name to your control? And when? And how? I mean, why can't you set the Caption property just after the Name property has been set?
Mario Vázquez ha scritto:
> Uh uh, > the property Name it's not allowed to be overrided... [quoted text clipped - 23 lines] >>>Thanks, >>>Mario Vazquez Mario Vázquez - 28 Dec 2005 15:45 GMT Ok, I just want the same behaivor than the GroupBox control. By default, the Text property it's set to the Name property. But only the first time you drag the control on the form. If later you change either the Name or Text property, this will not be do it again. That's it just what i want. But, the same question you made me I make meso: who gives the name to the Control? If I could hook that point it will be enough!
Thanks for interest!
Regards, Mario
> Ah, ok. > My question is: who gives the name to your control? And when? And how? I [quoted text clipped - 29 lines] >>>>Thanks, >>>>Mario Vazquez Carlo (MCP only) - 27 Dec 2005 11:17 GMT Try attaching an <Editor()> to your component, and then overrides the SetComonentDefaults method. hth C.
------------------------------------------- Carlo, MCP (Windows Based Applications) carlodevREMOVE@gmail.com
> Hello, > [quoted text clipped - 10 lines] > Thanks, > Mario Vazquez Mario Vázquez - 27 Dec 2005 14:25 GMT I don't find such method (SetComponentDefaults()) in the UITypeEditor class and EditorAttribute. To which class belongs?
thanks, Mario Vazquez
> Try attaching an <Editor()> to your component, and then overrides the > SetComonentDefaults method. [quoted text clipped - 19 lines] >> Thanks, >> Mario Vazquez Carlo (MCP only) - 28 Dec 2005 07:42 GMT No, it's inherited from a component designer. Try this:
Public Class MyControlDesigner Inherits ControlDesigner
Public Overrides Sub OnSetComponentDefaults() '... write your defaults here End Sub
End Class
<Editor(MyControlDesigner)>Public Class MyControl '... End Class
hth
Carlo
------------------------------------------- Carlo, MCP (Windows Based Applications) carlodevREMOVE@gmail.com
>I don't find such method (SetComponentDefaults()) in the UITypeEditor class >and EditorAttribute. [quoted text clipped - 26 lines] >>> Thanks, >>> Mario Vazquez Carlo (MCP only) - 28 Dec 2005 10:50 GMT Sorry for writing my previous reply very quickly. Mario, try this:
<Designer(GetType(MyControlDesigner), GetType(IDesigner))> _ Public Class MyClass Inherits Control '... End Class
Public Class MyControlDesigner Inherits ControlDesigner
Public Overrides Sub OnSetComponentDefaults() MyBase.OnSetComponentDefaults() Me.Control.Text = "write your default here" End Sub
End Class
hth
Carlo
------------------------------------------- Carlo, MCP (Windows Based Applications) carlodevREMOVE@gmail.com
>I don't find such method (SetComponentDefaults()) in the UITypeEditor class >and EditorAttribute. [quoted text clipped - 26 lines] >>> Thanks, >>> Mario Vazquez Mario Vázquez - 28 Dec 2005 15:46 GMT Thank You!!
I'll try and tell you
Regards, Mario
> Sorry for writing my previous reply very quickly. > Mario, try this: [quoted text clipped - 53 lines] >>>> Thanks, >>>> Mario Vazquez
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|