473,322 Members | 1,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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.ActiveControl.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 32195
Font is immutable. You cannot change its value. However, you can set the
Font property on the control you're working with, say,

this.ActiveControl.Font = new Font(this.ActiveControl.Font.FontFamily, 8.25,
this.ActiveControl.Font.Style);

-vJ

new Font(this.Font.FontFamily, 12, this.Font.Style);
"Jeff N" <Jeff N@discussions.microsoft.com> wrote in message
news:33**********************************@microsof t.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.ActiveControl.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
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...
0
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
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...
5
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...
3
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...
2
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,...
40
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...
18
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,...
3
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.