- Giới thiệu về Stock Tracker Widget - Công cụ theo dõi cổ phiếu bằng C# và WPF
- [VB.NET] Chia sẻ công cụ nhập số tiền tự động định dạng tiền tệ Việt Nam
- [VB.NET] Hướng dẫn fill dữ liệu từ winform vào Microsoft word
- [VB.NET] Hướng dẫn chọn nhiều dòng trên Datagridview
- GIỚI THIỆU TOOL: DUAL MESSENGER TOOLKIT
- [PHẦN MỀM] Giới thiệu Phần mềm Gmap Extractor
- Hướng Dẫn Đăng Nhập Nhiều Tài Khoản Zalo Trên Máy Tính Cực Kỳ Đơn Giản
- [C#] Chia sẻ source code phần mềm đếm số trang tập tin file PDF
- [C#] Cách Sử Dụng DeviceId trong C# Để Tạo Khóa Cho Ứng Dụng
- [SQLSERVER] Loại bỏ Restricted User trên database MSSQL
- [C#] Hướng dẫn tạo mã QRcode Style trên winform
- [C#] Hướng dẫn sử dụng temp mail service api trên winform
- [C#] Hướng dẫn tạo mã thanh toán VietQR Pay không sử dụng API trên winform
- [C#] Hướng Dẫn Tạo Windows Service Đơn Giản Bằng Topshelf
- [C#] Chia sẻ source code đọc dữ liệu từ Google Sheet trên winform
- [C#] Chia sẻ source code tạo mã QR MOMO đa năng Winform
- [C#] Chia sẻ source code phần mềm lên lịch tự động chạy ứng dụng Scheduler Task Winform
- [Phần mềm] Tải và cài đặt phần mềm Sublime Text 4180 full version
- [C#] Hướng dẫn download file từ Minio Server Winform
- [C#] Hướng dẫn đăng nhập zalo login sử dụng API v4 trên winform
[C#] Hiển thị hình ảnh GIF vào button, picturebox, label winform
Xin chào các bạn, bài viết hôm nay mình sẽ hướng dẫn các bạn cách chèn hình Gif và button, picturebox, hay label trong winform lập trình C#.
Bạn có thể hiển thị hình Gif thông qua thuộc tính BackgroundImage trong từng button trên.
Và các bạn chỉnh lại vị trí của hình theo nhu cầu của mình: trái, giữa hay bên phải tùy bạn.
Dưới đây là giao diện demo Button Gif C#:
Source code Animation Button Gif C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace howto_display_animated_gif
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
// Switch GIFs.
bool ButtonShowingPuppy = false;
private void btnGif_Click(object sender, EventArgs e)
{
ButtonShowingPuppy = !ButtonShowingPuppy;
if (ButtonShowingPuppy)
{
btnGif.Image = howto_display_animated_gif.Properties.Resources.puppy;
}
else
{
btnGif.Image = howto_display_animated_gif.Properties.Resources.under_construction;
}
}
// Switch GIFs, loading from files.
bool PictureBoxShowingPuppy = false;
private void picGif_Click(object sender, EventArgs e)
{
PictureBoxShowingPuppy = !PictureBoxShowingPuppy;
if (PictureBoxShowingPuppy)
{
picGif.Image = howto_display_animated_gif.Properties.Resources.puppy;
}
else
{
picGif.Image = howto_display_animated_gif.Properties.Resources.under_construction;
}
}
// Switch GIFs.
bool LabelShowingAlien = false;
private void lblGif_Click(object sender, EventArgs e)
{
string filename = Path.GetFullPath(
Path.Combine(Application.StartupPath, @"..\..\"));
LabelShowingAlien = !LabelShowingAlien;
if (LabelShowingAlien)
{
lblGif.Image = Image.FromFile(filename + "alien.gif");
}
else
{
lblGif.Image = Image.FromFile(filename + "under_construction.gif");
}
}
}
}