473,804 Members | 2,096 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to toggle label.Text Bold/Regular?

Could someone share how to toggle the font property of a label from regular
to bold and back to regular? I have tried label.Font.Bold = True but get the
error message that this property is ReadOnly. Label.Font.Styl e =
FontStyle.Bold --> ReadOnly error again. Any Suggestions appreciated.

Thanks
Nov 21 '05 #1
3 11482
"Rich" <Ri**@discussio ns.microsoft.co m> schrieb:
Could someone share how to toggle the font property of a label from
regular
to bold and back to regular? I have tried label.Font.Bold = True but get
the
error message that this property is ReadOnly. Label.Font.Styl e =
FontStyle.Bold --> ReadOnly error again. Any Suggestions appreciated.


\\\

' Removing bold style.
Me.Label1.Font = _
New Font(Me.Button1 .Font, Me.Label1.Font. Style And Not FontStyle.Bold)

' Adding bold style.
Me.Label1.Font = _
New Font(Me.Button1 .Font, Me.Label1.Font. Style Or FontStyle.Bold)
///

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

Nov 21 '05 #2
Thanks very much. This is consistent with what I came up with (finally)

Dim font1 As New Font("Aria", 10, FontStyle.Bold)
Label.Font = font1

Your methods seems more dynamic/efficient since I don't have to Dim each time.

Thanks again.

"Herfried K. Wagner [MVP]" wrote:
"Rich" <Ri**@discussio ns.microsoft.co m> schrieb:
Could someone share how to toggle the font property of a label from
regular
to bold and back to regular? I have tried label.Font.Bold = True but get
the
error message that this property is ReadOnly. Label.Font.Styl e =
FontStyle.Bold --> ReadOnly error again. Any Suggestions appreciated.


\\\

' Removing bold style.
Me.Label1.Font = _
New Font(Me.Button1 .Font, Me.Label1.Font. Style And Not FontStyle.Bold)

' Adding bold style.
Me.Label1.Font = _
New Font(Me.Button1 .Font, Me.Label1.Font. Style Or FontStyle.Bold)
///

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

Nov 21 '05 #3
try this i used to this in mirc chat .
Dim IsBold As Boolean = ((Label1.Font.B old And FontStyle.Bold) =
FontStyle.Bold)
Label1.Font = New Font(Label1.Fon t.Bold,
DirectCast(IIf( IsBold, Label1.Font.Bol d And Not FontStyle.Bold,
Label1.Font.Bol d Or FontStyle.Bold) , FontStyle))

Rich wrote:
Could someone share how to toggle the font property of a label from regular
to bold and back to regular? I have tried label.Font.Bold = True but get the
error message that this property is ReadOnly. Label.Font.Styl e =
FontStyle.Bo ld --> ReadOnly error again. Any Suggestions appreciated.

Thanks

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4139
by: johngilmer | last post by:
I have three radio buttons that are possible answers to a question. I have put them in a table and there is a label that goes with each radio button as its text. I would like to make some of the text of the label bold, so I have put <b> tags around the text I want bold. But it doesn't work; the text that should be bold is just regular. Any ideas would be appreciated. Thanks in advance. Here is the html: <table id="ANSWERS_4" border="0"...
2
8061
by: Roggey | last post by:
Hello I'm using System.Windows.Forms.Label and I want to add some text, where one or more words are bold or italic. I tried it with html tags but does not work. Somewhere i did read it should be done by html tags. I did it like this: label1.Text="my <b>test</b> string"; In the output i can see the html tags.<
2
1759
by: Peter Rilling | last post by:
Below is some code that I do not know why it does not work. Okay, as you can see it is simple HTML with two ASP:Label controls. Each label has some code that basically gets a string that will be written to the browser. ConditionalText.Eval is a method from my own library. As you can see, I have written some static text before and after the first Eval call. If I open this page, I get no content in the Label, even the static content. I...
11
4763
by: Mano | last post by:
When settiing a TreeNode to bold the text label of that node is clipped. As describedin in the Bug Rebort FDBK16963 I set the underliying TreeView Fond to be bold. Now I have the strange behavior, if I delete all childnodes, when the parent node is expanted, and rebuild all child treenodes, I can make an childnode bold without clipping it. If I make the same with an closed parent node so after rebulding all childnodes and expanting it,...
13
31437
by: =?Utf-8?B?S2VzdGZpZWxk?= | last post by:
Hi Our company has a .Net web service that, when called via asp.net web pages across our network works 100%! The problem is that when we try and call the web service from a remote machine, one outside of our domain, we get the error.. ** Client found response content type of 'text/html; charset=Windows-1252', but expected 'text/xml' **. We can discover the web service by typing in the url of the asmx so we know the server can 'see' it...
8
31041
by: Alexey Smirnov | last post by:
How to make bold part of the text in a Windows.Forms.Label? Thank you.
0
1537
by: Kevin McKinley | last post by:
Below i've put the code for a program that i wrote. I need help on lines 384-403. If you run this program you will notice on the first tab when have it produce an answer the $ is surrounded with {$}. How can i get rid of that? from Tkinter import * class MyApp: def __init__(self, parent): self.myparent = parent
0
1515
by: Guilherme Polo | last post by:
On Wed, Sep 3, 2008 at 8:57 PM, Kevin McKinley <kem1723@yahoo.comwrote: Come on.. "help on lines 384-403", that is not a good way to look for help. You are supposed to post some minimal code that demonstrates the problem. Anyway, this demonstrates what you are getting (independent of python version): import Tkinter
9
8030
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all I have a MDI Container Form, with one label control on the Background of this container form. When I now open a child form, this form is behind the label ... and this looks ugly ... :-)) When I set the label with "SendToBack", it completely disapears. I also tried to set the child form like "BringToFront" but this also does not help.
0
9715
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10600
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10352
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10354
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9175
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7642
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3835
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.