How do I use Font Awesome in window form?

Source: Internet
Author: User

With the development of technology, the previous Picture button on the web is now gradually replaced by the icon font, these icons are vector, vector diagram means that each icon can be in all sizes of the screen perfect, you can change the size and color at any time, and not distorted, really give people a "tall on" feeling. Because the font awesome is completely free, it is used by more than one person or commercial use. Fonts awesome A font file contains a lot of useful icons to help you fully express the meaning of each action on the Web page (better than the table, the table is better than the text).

The full set of icons from the Font awesome is completely bootstrap compatible, and they are a great team of partners. can be used with CSS very convenient to use, font awesome part of the font encoding (http://fontawesome.io/3.2.1/cheatsheet/) embodiment as shown:

But that's the problem? How to use it in the WinForm interface (and of course WPF is OK). After some research, finally found the "mystery":

The steps are as follows:

1 Download the font awesome to local, and install the modified font, the font name is Fontawesome.

2 Create a WinForm application and design the form interface as follows:

The code is as follows:

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.ComponentModel;4 usingSystem.Data;5 usingSystem.Drawing;6 usingSystem.Linq;7 usingSystem.Text;8 usingSystem.Windows.Forms;9 Ten namespaceWinformfont One { A      Public Partial classIconfontdemo:form -     { -          PublicIconfontdemo () the         { - InitializeComponent (); -             //must be a Unicode code -              This. Label1. Text ="\uf028"; +              This. Label1. Font =NewFont ("Fontawesome", -); -              This. Label1. ForeColor =Color.green; +             //must be a Unicode code A              This. TextBox1.Text ="\uf029 jackwangcumt"; at              This. Textbox1.font =NewFont ("Fontawesome", -); -              This. Textbox1.forecolor =Color.Black; -         } -  -         Private voidButton1_Click (Objectsender, EventArgs e) -         { in             intFontSize =int. Parse ( This. TextBox2.Text); -              This. Label1. Font =NewFont ("Fontawesome", fontsize); to              This. Textbox1.font =NewFont ("Fontawesome", fontsize); +         } -     } the}

3 run, the interface is as follows:

Change the font size and click Refresh to see that the font icons are getting bigger:

How font encoding is obtained:

You can use the caret in Word, select the font, and then click the desired icon to see the following Unicode encoding:

How do I use Font Awesome in window form?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.