Click here to Skip to main content
16,017,297 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a combo box it contains all the font name. If we select any font from combobox i want to change the textbox value to particular font style.
Posted
Comments
Uday P.Singh 12-Sep-11 6:38am    
are you looking to change font face or font style?

On Combobox SelectedIndex Changed Event

Font fnt = new Font(comboBox1.SelectedItem.ToString(), 9);
textBox1.Font = fnt;
 
Share this answer
 
On Comboxbox's selected index change event
yuo can do this

C#
textBox.Font="font"
txtxbox.Font.Style=FontStyle.Bold;
 
Share this answer
 
v2
ie: textBox1.Font = new Font("Comic Sans Cerif", 16, FontStyle.Regular);
 
Share this answer
 
v3
So, handle the Combobox SelectedIndexChanged or SelectedValueChnaged event, and set the Text,Box.Font property from the new selection.
 
Share this answer
 
Make a new font with the text of the selected item in the constructor. Then set the font of the textbox to the new font. You need to read the font size of the textbox font if you want to keep the size.

C#
Font font1 = new Font(comboBox1.SelectedItem.ToString(), textBox1.Font.Size);
textBox1.Font = font1;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900