Windows Develop Bookmark and Share   
 index > Windows Forms General > how to change font size in code?
 

how to change font size in code?

hi
i have label control in my windows form, sometimes the output that i want to set as the text property for the label is too long. how i can change the font size of the label in code??
thanks
FMZL  Saturday, September 26, 2009 11:42 PM
label1.Font = new Font(label1.Font.FontFamily, 13);

Hans Passant.
  • Marked As Answer byFMZL Sunday, September 27, 2009 9:20 AM
  •  
nobugz  Sunday, September 27, 2009 8:38 AM
Set the Font property. Doh.

Hans Passant.
nobugz  Saturday, September 26, 2009 11:58 PM
I know i can change it in designer through Font property but i dont know how to do it in code. Label.Font.Size property it a read-only. if you know tell me how?
FMZL  Sunday, September 27, 2009 7:44 AM
label1.Font = new Font(label1.Font.FontFamily, 13);

Hans Passant.
  • Marked As Answer byFMZL Sunday, September 27, 2009 9:20 AM
  •  
nobugz  Sunday, September 27, 2009 8:38 AM
thanks
FMZL  Sunday, September 27, 2009 9:20 AM

You can use google to search for other answers

Custom Search

More Threads

• dll import help
• Can you print a richtextbox using C++, without any C#?
• Prevent ContextMenu from closing and menu item size
• datagrid column header width
• Windows Form generic form
• removing Image from Listview's columnHeader not working on Vista
• Creating Handle to ToolStripButton
• MdiList-property in VS2005 ???
• tab and IsInputKey
• change the first form to be executed