Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / October 2005

Tip: Looking for answers? Try searching our database.

Overriding Default Button Text at Design-Time

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Glen - 26 Oct 2005 15:10 GMT
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.

Free Magazines

Get 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 ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.