473,796 Members | 2,520 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Label.Font.

Hello:

I have array of Label controls allocated danamically.

When I'm trying to change font as:
LabelLeft[i].Font.Strikeout = false;

I have error:

"Property or indexer 'System.Drawing .Font.Strikeout ' cannot be assigned to
-- it is read only"

Thank you.

May 9 '06 #1
3 9443
"dave" <da**@discussio ns.microsoft.co m> wrote in message
news:E5******** *************** ***********@mic rosoft.com...
Hello:

I have array of Label controls allocated danamically.

When I'm trying to change font as:
LabelLeft[i].Font.Strikeout = false;

I have error:

"Property or indexer 'System.Drawing .Font.Strikeout ' cannot be assigned to
-- it is read only"


I'd guess you need to create a new font.

MyLabel.Font = new Font(blah, blah);

Michael
May 9 '06 #2

dave wrote:
Hello:

I have array of Label controls allocated danamically.

When I'm trying to change font as:
LabelLeft[i].Font.Strikeout = false;

I have error:

"Property or indexer 'System.Drawing .Font.Strikeout ' cannot be assigned to
-- it is read only"


What we think of as 'changing a property of the font' must be expressed
as 'assigning a new font which is the same as the old font except for
that particular property'. This code flips the current strikeoutness:
bool isStruckOut = LabelLeft[i].Font.Strikeout ;
Font currentFont = LabelLeft[i].Font;

if (isStruckOut)
// to remove a style component we must get the
// current style and unset the relevant bit
// with a bitmask
LabelLeft[i].Font = new Font(currentFon t,
currentFont.Sty le & ~FontStyle.Stri keout);
else
// adding a style component is easy
LabelLeft[i].Font = new Font(currentFon t,
FontStyle.Strik eout);

--
Larry Lard
Replies to group please

May 10 '06 #3
dave wrote:
Hello:
I have array of Label controls allocated danamically.
When I'm trying to change font as:
LabelLeft[i].Font.Strikeout = false;

I have error:

"Property or indexer 'System.Drawing .Font.Strikeout ' cannot be assigned to
-- it is read only"


Try:

LabelLeft[i].Font = new Font(LabelLeft[i].Font, LabelLeft[i].Font.Style & ~FontStyle.Stri keout);
May 10 '06 #4

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

Similar topics

4
12346
by: Stuart Norris | last post by:
Dear Readers, I am attempting to draw box around some text using unicode on multiline label. The label is forty characters wide and 12 lines deep. I have been trying to draw a box around text (centered in the label) on this label. My font on this label is Courier new - hence fixed width character cells.
1
1907
by: Venki | last post by:
I have a textbox to enter an email address followed by a telephone textbox. The email has a regularexpressionvalidator and a requiredfieldvalidator. The ReqField works fine, but if I put in an invalid email addy then click in the telephone field below, something very odd happens. The telephone label & textbox (and all controls below) shift down one line, and rather than having my cursor in the telephone textbox. The cursor is in the...
2
1757
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...
2
5833
by: KV | last post by:
Hi, I'm new to VB.NET and I'm trying to do something rather simple that has turned out to be a pain in the hindside. I'm developing a webpart. All I want to do is change the font of a label on it. The label is created at runtime. I use the following code: Dim lblDate as Label = New Label lblDate.Text = Date.Today
3
11478
by: Rich | last post by:
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.Style = FontStyle.Bold --> ReadOnly error again. Any Suggestions appreciated. Thanks
7
19550
by: Joe | last post by:
I have a label control that will be filled with text at runtime. The length of the text will vary, but the label must stay the same size. Is there a way to set the font size of the text such that it completely fills the label? For example, if the text is "Santa Claus" the font size might have to be 130 points to fill up a 637x476 label, where if the text is "Once upon a midnight dreary / while I pondered weak and weary / over many a...
1
3894
by: | last post by:
I have a label control that I've embedded in a datalist template. I will be binding data to that label. I want to run a string formatting function on the database text before it is injected into the datalist. When I try to do this, I get a "... does not exist in the current context. I need to know how to target the control. If I were writing Flash actionscript, it would be something like
0
1535
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
1514
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
6
8853
by: Miro | last post by:
Is there a way to / or a mathematical formula to see if a font size is 'too big' for a label. I have a label that is docked to 'fill' a form, and I want to resize that font based on the width and height of the label. So far I have something like this on the Form_Resize event: Label2.Font = New Font(Label2.Font.Name, _ Label2.Size.Height - 100, Label2.Font.Style)
0
9680
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
9528
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10455
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...
1
10173
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
9052
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
7547
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
6788
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();...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.