- [DEVEXPRESS] Hỗ trợ tìm kiếm highlight không dấu và không khoảng cách trên Gridview Filter
- [C#] Chia sẻ source code phần mềm Image Downloader tải hàng loạt hình ảnh từ danh sách link url
- [C#] Chụp hình và quay video từ camera trên winform
- [C#] Chia sẽ full source code tách file Pdf thành nhiều file với các tùy chọn
- Giới thiệu về Stock Tracker Widget - Công cụ theo dõi cổ phiếu và cảnh báo giá tăng giảm 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
- 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
- [C#] Hướng dẫn download file từ Minio Server Winform
[C#] Viết ứng dụng Auto Fill list Textbox from clipboard Winform
Xin chào các bạn, bài viết hôm nay mình tiếp tục hướng dẫn các bạn cách auto fill dữ liệu từ clipboard windows vào danh sách Textbox trên C#, winform.
[C#] Auto fill data from clipboard to list TextBox
Dưới đây, là hình ảnh demo ứng dụng:

Như hình trên, các bạn thấy ở trường dữ liệu nhập số căn cước công dân (CCCD).
Nó bao gồm 12 control Textbox như hình trên.
Khi chúng ta copy một dãy dữ liệu và kiểm tra nó đúng 12 số và không tồn tại ký tự đúng format của số căn cước công dân, thì chúng ta sẽ điền chúng vào tất cả Textbox trên.
Video demo ứng dụng:
Full source code C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FillFormClipboard
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            foreach (Control control in panel1.Controls)
            {
                if (control is TextBox)
                {                   
                    TextBox textBox = (TextBox)control;
                    textBox.KeyDown += TextBox_KeyDown;
                    textBox.KeyPress += TextBox_KeyPress;
                }
            }
        }
        private void TextBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            // chỉ cho phép nhập số
            if (!char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar))
            {                
                e.Handled = true;
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
        }
        private void TextBox_KeyDown(object sender, KeyEventArgs e)
        {
           
            if (e.Control && e.KeyCode == Keys.V)
            {               
                HandlePasteEvent((TextBox)sender);
            }
        }
        private void HandlePasteEvent(TextBox textBox)
        {
           
            if (Clipboard.ContainsText())
            {
                string clipboardText = Clipboard.GetText().Trim().Replace(" ","");
                var regex = new Regex(@"^\d{12}$");
                if (clipboardText.Length == 12 && regex.IsMatch(clipboardText))
                {
                    char[] characters = clipboardText.ToCharArray();
                    foreach (Control control in panel1.Controls)
                    {
                        if (control is TextBox)
                        {
                            var nameControl = control.Name;
                            var i = Convert.ToInt16(nameControl.Split('_').LastOrDefault()) - 1;
                            control.Text = characters[i].ToString();
                        }
                    }
                }
            }
        }
    }
}
Thanks for watching!

![[C#] Viết ứng dụng Auto Fill list Textbox from clipboard Winform](https://laptrinhvb.net/uploads/users/9a8cb514e4428e85fb4ca07588e9103f.png)

![[C#] Hướng dẫn lấy thông tin tỷ giá vàng SJC sử dụng API](https://laptrinhvb.net/uploads/source/vbnet/ty_gia_vang.png)
![[C# - VB.NET] Download async multiple files và hiển thị trên ListView winform](https://laptrinhvb.net/uploads/source/csharp/download_file_thumb.png)
![[C#] Giới thiệu website QuickType.io dùng để tạo class POCO từ Json](https://laptrinhvb.net/uploads/source/vbnet/quicktype.png)
![[C#] Hướng dẫn thêm cookie vào Http Request website](https://laptrinhvb.net/uploads/source/image_baiviet/fa5037db1a223b7275bad44d9b7950f5.jpg)
![[C#] Hướng dẫn push notification sử dụng API One Signal](https://laptrinhvb.net/uploads/source/csharp/one_signal_thumb.png)
![[C#] Bắt sự kiện bàn phím chuột bên ngoài ứng dụng winform sử dụng thư viện MouseKeyHook](https://laptrinhvb.net/uploads/source/vbnet/mouse-keyboard-hook-logo.png)
![[C#] Empty Recycle Bin trong lập trình csharp](https://laptrinhvb.net/uploads/source/image_baiviet/5ffdaade6ca87e295ce10f4bcb715c04.jpg)
![[C#] Hướng dẫn chuyển đổi số int sang dạng text giống column name trên Excel](https://laptrinhvb.net/uploads/source/new_image_baiviet/col_name_excel.jpg)
![[C#] Tạo hình ảnh thumbnail hàng loạt so sánh sử dụng bất đồng bộ và Parallel Async](https://laptrinhvb.net/uploads/source/csharp/Thumbnails_image_app_thumb.jpg)
![[C#] Download Source code chương trình quản lý phòng NET - lập trình Socket C#](https://laptrinhvb.net/uploads/source/image_baiviet/4de38f36795e94e372bb449042c2ad4f.png)
![[C#] Hướng dẫn sử dụng Cookie trong Selemium](https://laptrinhvb.net/uploads/source/csharp/selemium_cookie_thumb.png)

![[C#] Tìm tất cả thiết bị trong cùng lớp mạng Lan](https://laptrinhvb.net/uploads/source/csharp/find_device_lan_thumb.png)

![[C#]  Quản lý dịch vụ Windows Services trên Csharp Winform](https://laptrinhvb.net/uploads/source/new_image_baiviet/windows_services.jpg)
![[C#] Hướng dẫn cách viết sự kiện event cho usercontrol trong winform](https://laptrinhvb.net/uploads/source/csharp/envent_usercontrol_thumb.jpg)
![[C#] Hướng dẫn Supend and Resume Process ID in Winform](https://laptrinhvb.net/uploads/source/new_image_baiviet/supend_resume.jpg)
![[C#] Hướng dẫn ngắt kết nối mạng card ethenet trong windows](https://laptrinhvb.net/uploads/source/csharp/ethenet_csharp_thumb.jpg)
![[C#] Chia sẽ hàm bỏ dấu tiếng việt trong lập trình Csharp](https://laptrinhvb.net/uploads/source/image_baiviet/3b7f5fe03e368394ff8bd6a95d94ecbf.jpg)
![[C#] Hướng dẫn sử dụng ngăn xếp Stacks  và  hàng  đợi Queues trong Winform](https://laptrinhvb.net/uploads/source/csharp/c-code-snippets-queue-and-stack.png)
![[C#] Hướng dẫn thêm, xóa, sửa database ORACLE trong lập trình csharp](https://laptrinhvb.net/uploads/source/image_baiviet/79715e90242046fc881fd2058e579356.jpg)
![[C#] Bắt lỗi sự kiện control sử dụng Error Provider trong lập trình csharp](https://laptrinhvb.net/uploads/source/image_baiviet/d84a548957738f58401d868f330ccb8c.gif)
![[C#] Hướng dẫn chạy Script Windows Power Shell trong lập trình Winform](https://laptrinhvb.net/uploads/source/csharp/power_shell_csharp_thumb.png)
![[C#] Xem thông tin đăng ký tên miền Who is Domain](https://laptrinhvb.net/uploads/source/vbnet/whois_domain_thumb.jpg)
![[C#] Hướng dẫn custom label Winform thành Auto Resize Label](https://laptrinhvb.net/uploads/source/image_baiviet/7b787aa8f551aab0050759067efc5fcd.jpg)
