473,657 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change Font Size of a Label

How can I change the font size of a label?

I have:

Label1.Font.Siz e = "12"

but it's telling me that property 'Size' is readonly.

Thanks,

-Dave
Nov 21 '05 #1
2 41179
Me.Label1.Font = New System.Drawing. Font("Microsoft Sans Serif", 12.0!,
System.Drawing. FontStyle.Regul ar, System.Drawing. GraphicsUnit.Po int,
CType(0, Byte))

Whenever you can't do something in code that you do in the designer, look at
how the code in the designer does it. There is nothing special going on in
the "Windows Form Designer generated code" Whatever the designer can do,
you can do too.

Hope it helps

Chris

"Dave" <no****@yahoo.c om> wrote in message
news:e3******** ******@TK2MSFTN GP11.phx.gbl...
How can I change the font size of a label?

I have:

Label1.Font.Siz e = "12"

but it's telling me that property 'Size' is readonly.

Thanks,

-Dave

Nov 21 '05 #2
"Dave" <no****@yahoo.c om> schrieb:
How can I change the font size of a label?

I have:

Label1.Font.Siz e = "12"

but it's telling me that property 'Size' is readonly.


You will have to create a new 'Font' object with the appropriate font size:

\\\
Me.Font = _
New Font( _
Me.Font.FontFam ily, _
200, _
Me.Font.Style, _
GraphicsUnit.Pi xel _
)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #3

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

Similar topics

2
57232
by: Bjoern | last post by:
Hi all, how can i change the Font Size of the Text in my Label. I will change it dynamic in the code. I tryed: int number = 11; label1.Font.Size = number; But this is not possible because Size is Write-Protected. There is only a Get-Method and no Set. Plz Help
0
1543
by: csgraham74 | last post by:
Hi there, i have creted a datagrid control to display images using the following code. <asp:DataGrid id="dg_Properties" runat="server" HorizontalAlign="Center" Width="450px" AutoGenerateColumns="False" ShowHeader="False"> <Columns><asp:BoundColumn Visible="False" DataField="Property_ID" HeaderText="Property_ID"></asp:BoundColumn><asp:TemplateColumn><ItemTemplate><table
7
19529
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...
18
24953
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin, that IE7 does not seem to offer any way to control the font size of a text input element.
10
3578
by: apparker | last post by:
I'm creating a new GUI for a program and it is for a medical exam. There are so many different things to ask someone during a history it wastes too much space to make checkboxes for everything so I had an idea: Can I simply create a list of conditions and when the doctor clicks them, they turn red? And clicking them again would make them default again? This would really make the exam better since the doctor could quickly glance at a...
1
2600
by: dhaneshrs | last post by:
I have a small code that shows inactive and active users from the ms access DB. <%@ Page Language="VB" MasterPageFile="~/MasterPageAdmin.master" Title="Welcome" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.OleDb" %> <%@ Import Namespace="System.Drawing" %> <script language="VB" runat="server"> Public Function GetInActiveDays(ByVal strLastLoginDate As String) As Integer Dim date1 As Date = New...
2
1771
RedSunFlowers32
by: RedSunFlowers32 | last post by:
Hi - I am creating a form for my personal business site. I want people to be able to get their own shipping total for the item(s) they have purchased. I have another code from a different file I want to use. I am unclear on which lines to remove to stop the pop-up windows from asking the user to input their information. Could someone please point this out to me? Thank you! Current code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
6
8827
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)
2
3628
by: kheitmann | last post by:
OK, so I have a blog. I downloaded the "theme" from somewhere and have edited a few areas to suit my needs. There are different font themes within the page theme. Long story short, my "Text Posts" are supposed to be in the font: Georgia, but they are showing up in "Times New Roman"...blah! I can't find anything wrong in the code, but who am I trying to fool? I know nothing about this stuff. The code is below. The parts that I *think*...
0
8312
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
8732
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
8504
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
7337
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
6169
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
5632
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
4159
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...
2
1959
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1622
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.