Click here to Skip to main content
15,905,587 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,
I want to change a textbox font in runtime!
Please help me.

Example:

I designed a form with a textbox. the textbox font is "Microsoft Sans Serif". Now I want to change the font to "Tahoma".
I need to create a Multi Language Application.

Please help me
Posted
Updated 24-Jan-11 2:59am
v2

Instead of setting your own fonts, another thing to consider is using the SystemFonts class

This will then use the font the user has currently selected in their Appearance settings

http://msdn.microsoft.com/en-us/library/system.drawing.systemfonts%28v=vs.85%29.aspx[^]

e.g. set the font property of the form in your ctor

C#
public class YourForm : Form
{
    public YourForm()
    {
        this.Font = SystemFonts.MessageBoxFont;
    }
}
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 24-Jan-11 10:35am    
Not answering to the original question is best answer - my 5
--SA
sat80890 29-Jan-11 2:22am    
tnx
You can try this
textBox1.Font = new Font("Tahoma", 12);
 
Share this answer
 
Comments
sat80890 29-Jan-11 2:22am    
tnx
C#
TextBox1.Font = new Font(new FontFamily("Tahoma"), TextBox1.Font.Size, TextBox1.Font.Style, TextBox1.Font.Unit);


This way you can retain the style if you have specified any.
 
Share this answer
 
v4
Comments
sat80890 29-Jan-11 2:22am    
tnx
Prerak Patel 29-Jan-11 10:35am    
You are welcome.

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