- [DATABASE] Hướng dẫn thêm và cập nhật Extended Property Column trong Table Sqlserver
- [DEVEXPRESS] Hướng dẫn sử dụng Vertical Gridview để hiển thị thông tin sản phẩm
- [C#] Hướng dẫn sử dụng Json Schema để Validate chuỗi string có phải json
- [C#] Hướng dẫn sử dụng công cụ Clean Code trên Visual Studio
- [C#] Hướng dẫn Drag and Drop File vào RichTextBox
- [C#] Hướng dẫn tạo hiệu ứng Karaoke Text Effect Winform
- [C#] Sử dụng thư viện ZedGraph vẽ biểu đồ Line, Bar, Pie trên Winform
- [DATABASE] Hướng dẫn sort sắp xếp địa chỉ IP trên sqlserver sử dụng hàm PARSENAME
- [C#] Theo dõi sử kiện process Start hay Stop trên Winform
- [ASP.NET] Chia sẻ source code chụp hình sử dụng camera trên website
- [C#] Chạy ứng dụng trên Virtual Desktop (màn hình ảo) Winform
- [C#] Mã hóa và giải mã Data Protection API trên winform
- [C#] Hướng dẫn tạo Gradient Background trên Winform
- [DATABASE] Hướng dẫn convert Epoch to DateTime trong sqlserver
- [DATABASE] Hướng dẫn sử dụng STRING_AGG và CONCAT_WS trong sqlserver 2017
- [C#] Hướng dẫn Copy With All Property in Class Object
- [DEVEXPRESS] Hướng dẫn load Json DataSource vào GridView
- [C#] Hướng dẫn tạo chữ ký trên winform Signature Pad
- [DEVEXPRESS] Format code T-SQL highlight in RichEditControl
- [C#] Hướng dẫn upload file, hình ảnh từ Winform lên server API ASP.NET Core
[C#] Hướng dẫn sử dụng Font Awesome làm icon trong Winform
Xin chào các bạn, bài viết hôm nay mình sẽ tiếp tục hướng dẫn các bạn cách sử dụng Font Awesome để lấy icon cho phần mềm ứng dụng của mình trên ngôn ngữ lập trình C# Winform.
[C#] Tutorial Use FontAwesome in Winform
Font Awesome là một thư viện font bao gồm các icon phổ biến thường được sử dụng, do là icon font nên chúng ta sẽ dễ dàng thay đổi màu sắc và kích thước mà không làm bể điểm ảnh,
nghĩa là chúng ta zoom lớn hay nhỏ nó vẫn rõ nét.
Nếu các bạn nào đang lập trình website chắc cũng biết về bộ font nổi tiếng này, thường được sử dụng trong các website hiện nay.
Dưới đây là các icon của Font Awesome:
Còn rất là nhiều hình nằm ở bên dưới nữa nhé các bạn, bạn có thể truy cập vào trang chủ của FontAwesome để xem chi tiết.
Demo ứng dụng Winform C# sử dụng Font Awesome:
Đầu tiên, các bạn cần cài đặt thư viện font-awesome vào hệ thống của windows.
Trong thư mục Debug khi các bạn download source code ở cuối bài viết các bạn click mở file: fontawesome-webfont.ttf
để cài đặt vào thư viện font của windows.
Các bạn nhìn giao diện demo trên là các bạn thấy mình có thể thay đổi màu sắc một cách dễ dàng.
Trong bài viết có tích hợp sẵn một file font.cs
.
Cách sử dụng chèn Icon vào Listview:
private void Form1_Load( object sender, EventArgs e ) {
listView1.Font = Fonts.FontAwesome;
listView1.Items.Add( Fonts.fa.amazon );
listView1.Items.Add( Fonts.fa.google );
listView1.Items.Add( Fonts.fa.github_square );
listView1.Items.Add( Fonts.fa.hotel );
listView1.Items.Add( Fonts.fa.microphone );
listView1.Items.Add( Fonts.fa.motorcycle );
listView1.Items.Add( Fonts.fa.object_group );
listView1.Items.Add( Fonts.fa.send_o );
listView1.Items.Add( Fonts.fa.server );
listView1.Items.Add( Fonts.fa.list_alt );
listView1.Items.Add( Fonts.fa.map_signs);
listView1.Items.Add(Fonts.fa.child);
listView1.Items.Add(Fonts.fa.chevron_circle_right);
listView1.Items.Add(Fonts.fa.linux);
listView1.Items.Add(Fonts.fa.home);
listView1.Items.Add(Fonts.fa.soundcloud);
listView1.Items.Add(Fonts.fa.hourglass);
listView1.Items.Add(Fonts.fa.folder);
listView1.Items.Add(Fonts.fa.folder_open);
listView1.Items.Add(Fonts.fa.server);
listView1.Items.Add(Fonts.fa.list_alt);
listView1.Items.Add(Fonts.fa.television);
listView1.Items.Add(Fonts.fa.child);
listView1.Items.Add(Fonts.fa.chevron_circle_right);
listView1.Items.Add(Fonts.fa.linux);
listView1.Items.Add(Fonts.fa.home);
listView1.Items.Add(Fonts.fa.soundcloud);
listView1.Items.Add(Fonts.fa.hourglass);
listView1.Items.Add(Fonts.fa.folder);
listView1.Items.Add(Fonts.fa.folder_open);
listView1.Items.Add(Fonts.fa.server);
listView1.Items.Add(Fonts.fa.list_alt);
listView1.Items.Add(Fonts.fa.television);
}
private void btn_changeColor_Click(object sender, EventArgs e)
{
if(colorDialog1.ShowDialog() == DialogResult.OK)
{
listView1.ForeColor = colorDialog1.Color;
}
}
THANKS FOR WATCHING!