473,760 Members | 9,717 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing a Control's Font Size during runtime

It it possible to change a button's or text box's font size during runtime?

When I try to build my application with this code:
this.ActiveCont rol.Font.Size = "8.25";
I get this error message:
Property or indexer "System.Drawing .Font.Size' cannot be assigned to -- it
is read only

I can change a button's text property during runtime, but I'd also like to
change the font size as well.
Nov 16 '05 #1
1 32233
Font is immutable. You cannot change its value. However, you can set the
Font property on the control you're working with, say,

this.ActiveCont rol.Font = new Font(this.Activ eControl.Font.F ontFamily, 8.25,
this.ActiveCont rol.Font.Style) ;

-vJ

new Font(this.Font. FontFamily, 12, this.Font.Style );
"Jeff N" <Jeff N@discussions.m icrosoft.com> wrote in message
news:33******** *************** ***********@mic rosoft.com...
It it possible to change a button's or text box's font size during
runtime?

When I try to build my application with this code:
this.ActiveCont rol.Font.Size = "8.25";
I get this error message:
Property or indexer "System.Drawing .Font.Size' cannot be assigned to -- it
is read only

I can change a button's text property during runtime, but I'd also like to
change the font size as well.

Nov 16 '05 #2

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

Similar topics

23
3763
by: BobK | last post by:
Hello Everyone, I am updating the CSS for my site but want new and original page to appear the same. My original CSS permits small increments of zooming (ctrl/mouse wheel) so that you get perhaps 3 usable levels of zoom. The increments are small and it only has 4 zoom levels. Same thing with changing resolutions. When you change from 1280x1024 to 800x600 the page looks acceptable after changing the zoom a click or two.
0
987
by: Eitan | last post by:
Hello, How can I change, within my code, the display font size from 96 DPI to 120 DPI? I would like to do it using either MFC or the Win32 SDK. Thanks, Eitan
1
4373
by: Tom Rahav | last post by:
Hello. I use visual basic .net 2003 and Crystal Reports for creating win-reports. My question is if there is any possibility to set font properties (type, color and size) of a text control or data field during runtime. To be more accurate, I know I can set these settings by formula (next to each property in design time), but I would like to let the user choose what font settings he would like to use. I allow the user to set there...
5
27845
by: dixie | last post by:
I want to be able to set the font size and font type for text in a text box on a report using VBA. I wan't to be able to control it from a setting in a table. The problem is that I don't know the syntax for setting either font type or font size for a text box on a report. Does anyone know? Help. Please! dixie
3
1682
by: Punisher | last post by:
I have a datagrid that I want to move another part of the page. I'm able to do this but the datagrid looses it's values after the move. General_DataGrid_CurrentItems is the datagrid name. I want to move it to a tablecell called tdControls. this.Controls.Remove(General_DataGrid_CurrentItems); tdControls.Controls.Add(General_DataGrid_CurrentItems); This works. It moves the datagrid from the bottom of the page to the middle
2
1547
by: iwdu15 | last post by:
ok, now i had a similar question involving changing colors from GDI to web, and i couldnt find a font translator class so here i am. I am trying to change rtf to html (w/o 3rd party extensions, since i only need to convert text) and when i attemp to get the font size from a rich text box and show it in a WebBrowser control, the size is way too big. how can i get the font size rite? if tried Me.rtbText.Font.Size and
40
2976
by: Paul Davis | last post by:
Hi all, I'm building some style sheets and trying to play the old game of balancing designer pixel perfection and still allowing users to adjust their font sizes. The compromise I've made with the designer is that he'll accept allowing users to change font sizes it it "looks right" with the default setting. I'm using em to set the font size. So, anyway, here's the problem. At 0.96em we get the perfect font size. But, if the font is...
18
25004
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.
3
4144
by: MLH | last post by:
Without modifying the default font settings everywhere, is there any way to specify it for just message boxes? MsgBox "I would like this text to be larger for all message boxes." ???
0
9521
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
9333
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
10107
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
9945
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
9900
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
9765
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7324
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
5214
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...
3
2733
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.