473,692 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic Font change for buttons

Jim
Working with VB.net under VS.Net 2003.

Have a simple form with a Button1. I want to change the
font on the button when the button is clicked.

Is there a way to Dynamically change the Font for Button1
from regular to bold, change the size etc. This line of
code:
Button1.Font.Bo ld = True

gives an error:
property is read only.

I know it can be changed in the designer, but the users
would like some further emphasis in the button label if
the button has been clicked.

What am I missing?

Thanks
Nov 21 '05 #1
2 16206
Button1.Font = New Font(Button1.Fo nt, FontStyle.Bold)

Button1.Font = New Font(Button1.Fo nt, FontStyle.Bold Or FontStyle.Itali c)

The properties of Button.Font are read-only. So if you need to change any
properties, just create a new font from the existing one with the changed
property(ies) and assign it to Button.font.

hope that helps..
Imran.

"Jim" <an*******@disc ussions.microso ft.com> wrote in message
news:11******** *************** *****@phx.gbl.. .
Working with VB.net under VS.Net 2003.

Have a simple form with a Button1. I want to change the
font on the button when the button is clicked.

Is there a way to Dynamically change the Font for Button1
from regular to bold, change the size etc. This line of
code:
Button1.Font.Bo ld = True

gives an error:
property is read only.

I know it can be changed in the designer, but the users
would like some further emphasis in the button label if
the button has been clicked.

What am I missing?

Thanks

Nov 21 '05 #2
Thanks - that works.
-----Original Message-----
Button1.Font = New Font(Button1.Fo nt, FontStyle.Bold)

Button1.Font = New Font(Button1.Fo nt, FontStyle.Bold Or FontStyle.Itali c)
The properties of Button.Font are read-only. So if you need to change anyproperties, just create a new font from the existing one with the changedproperty(ies ) and assign it to Button.font.

hope that helps..
Imran.

"Jim" <an*******@disc ussions.microso ft.com> wrote in messagenews:11******* *************** ******@phx.gbl. ..
Working with VB.net under VS.Net 2003.

Have a simple form with a Button1. I want to change the
font on the button when the button is clicked.

Is there a way to Dynamically change the Font for Button1 from regular to bold, change the size etc. This line of
code:
Button1.Font.Bo ld = True

gives an error:
property is read only.

I know it can be changed in the designer, but the users
would like some further emphasis in the button label if
the button has been clicked.

What am I missing?

Thanks

.

Nov 21 '05 #3

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

Similar topics

0
1893
by: hzgt9b | last post by:
Using VS 2003, VB.NET: I have a TreeView control filled with TreeNodes. When I create the TreeView, I set HotTracking = True. Subsequently, I change the font (make the not bold versus bold) on several of the TreeNodes in the TreeView but now, on those changed nodes, the underline from the HotTracking no longer appears on the screen (but, while being hovered over, the node still gets the HotTracking font color change and the background...
6
1878
by: Mason A. Clark | last post by:
I came upon this trick: a usemap with two buttons for changing the page's font size: ============ <map name="fontmap" id="fontmap"> <area shape="rect" coords="111,1,126,15" href="http://niemanwatchdog.org/index.cfm?fontsize=up"> <area shape="rect" coords="127,0,143,14"
2
8751
by: Hariharan S | last post by:
Hi Guys, Have an issue with the Font object. I have a text box in which I can enter text and I have included a small button which upon selection, should enable me to change the newly entered text into bold. But it is not what is happening. All the previous information entered in the regular font too gets changed to bold. The code on the button click event handler is as follows ...
0
1406
by: Dan Neely | last post by:
Winform labels, buttons, etc don't respond to the normal/large/extra large font settings that can be specified in display properties. Is there an easy way to do an appwide detection+change at runtime for accescibility purposes? I realize the bigger fonts will make things "interesting" regarding layout in places, but if simply detecting and doing the font change is a major effort the other problem is a moot point.
0
1661
by: RSB | last post by:
Hi Every one, i am trying to create a UserControl and i am passing a Array of strings to it. Now based on the Array elements i am creating the LinkButtons Dynamically. I am also passing a Event to this control and Lining the OnClick event of these LinkButtons to this Event. (Which works fine). Now the Thing which i cannot achieve is i want to Change the Back Color of the Clicked to LinkButton To a different color and i also don't want to...
1
2233
by: Rajesh Joshi | last post by:
How to Change Datagrid's Column font change for a column. and How fill Msflexgrid fill with particular Recordset at runtime.
1
14620
by: Lennart Nielsen | last post by:
How do you change the font size dynamically in a single selected cell? Lennart
22
7957
by: Saul | last post by:
I have a set of radio buttons that are created dynamically, after rendered I try loop thru this set by getting the length of the set, but I keep getting an error stating the element is undefined. I am using getElelementsByName since these are radio buttons, but it seems that the dynamic element is not seen!!! This is my code... please let me know if there is anything that I am doing wrong! - thanks ---- ....
0
1131
by: Dhans | last post by:
I have a MDI Application. From the container form I am setting the font for the each controls in the MDI Child form. If I increase the size of the font greater than the default, the text in each control displays the bigger size as expected. But the location of the controls are changes and the GUI does not look good. How do i prevent this location change in each controls, if i change the font size in control?
0
9083
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
8960
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...
0
7627
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...
0
5818
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
4323
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...
0
4557
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2972
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
2
2237
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1957
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.