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 / January 2008

Tip: Looking for answers? Try searching our database.

fontstyle problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kamran - 21 Jan 2008 04:49 GMT
Hi!
In vb .net (2005) i want when a user clicks a button it's font become bold.
i have used the following line of code in click event of that button but it
returns error:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Me.Button1.Font.Bold = True

End Sub

what's wrong with me?

Best wishes.
Jack Jackson - 21 Jan 2008 05:59 GMT
>Hi!
>In vb .net (2005) i want when a user clicks a button it's font become bold.
[quoted text clipped - 8 lines]
>
>what's wrong with me?

When you get an error, you should tell us what that error is. However,
it is clear what your problem is.  Font attributes can not be changed.
You must create a new Font object:

Me.Button1.Font = New Font(Me.Button1.Font, FontStyle.Bold)
Herfried K. Wagner [MVP] - 21 Jan 2008 15:17 GMT
"Jack Jackson" <jjackson@cinnovations.net> schrieb:
> When you get an error, you should tell us what that error is. However,
> it is clear what your problem is.  Font attributes can not be changed.
> You must create a new Font object:
>
> Me.Button1.Font = New Font(Me.Button1.Font, FontStyle.Bold)

If the button does not have a 'Font' object assigned which is shared by more
than one control:

\\\
Using OldFont As Font = Me.Button1.Font
   Me.Button1.Font = New Font(Me.Button1.Font, FontStyle.Bold)
End Using
///

This will dispose the old font after assigning the new one.

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>

Kevin Spencer - 21 Jan 2008 12:12 GMT
You can't change a font properties. You have to create a new font instance.

Signature

HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP

> Hi!
> In vb .net (2005) i want when a user clicks a button it's font become
[quoted text clipped - 10 lines]
>
> Best wishes.

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.