Could someone please tell me how to override the default text when
placing a custom control on the design surface?
I have created a button control that inherits from
System.Windows.Forms.Button. The only things I want to happen at
design time is that the button is sized to specific size, an image is
set to specific image and the button text is blank.
I have no problem with the other issues, but even though I set the
button text to string.empty at construction, it comes up with the usual
default of {buttonName}1.
Where can I override this?
Thanks,
Glen Wolinsky
alantolan@users.com - 26 Oct 2005 16:27 GMT
Try overriding InitLayout().
It can be used to set the size and text (didn't test the image).
hth,
Alan.
Glen - 26 Oct 2005 16:49 GMT
Alan,
Thanks for the reply. I tried InitLayout per your instructions, but it
didn't seem to have the desired result. However, I then tried
overriding the OnPain event and that seemed to do the trick without any
adverse effects. My code is pasted below.
Thanks again for your help,
Glen
-------------------------------------------------------------------------------------------------------------------------------------------------
Protected Overrides Sub OnPaint(ByVal pevent As
System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(pevent)
MyBase.Text = String.Empty
End Sub
-------------------------------------------------------------------------------------------------------------------------------------------------
Claes Bergefall - 27 Oct 2005 10:32 GMT
Try this:
http://groups.google.se/group/microsoft.public.dotnet.framework.windowsforms/msg
/df04e91fc95651ea
/claes
> Could someone please tell me how to override the default text when
> placing a custom control on the design surface?
[quoted text clipped - 12 lines]
> Thanks,
> Glen Wolinsky
Glen - 28 Oct 2005 17:46 GMT
Claes,
That did the trick! That was my very first adventure into custom
designers. It sounded so intimidating until I tried it out. It's
SOOOO easy....well, at least for the simple things.
Thanks alot for your help.