- [C#] Hướng dẫn convert HTML code sang PDF File trên NetCore 7 Winform
- [C#] Hướng dẫn viết ứng dụng chat với Gemini AI Google Winform
- Hướng dẫn khóa file bằng nhiều process id, không cho xóa tập tin
- Hướng dẫn cách tạo Product Id cho ứng dụng phần mềm XXXXX-XXXXX-XXXXX-XXXXX
- [SQLSERVER] Hướng dẫn tạo script sql từ ứng dụng Sqlserver management Studio
- [C#] Hướng dẫn sử dụng thư viện AutoITx lấy id và password Ultraviewer trên winform
- [VB.NET] Hướng dẫn lấy thông tin tài khoản đăng nhập windows và khởi động lại ứng dụng ở chế độ Administrator
- [C#] Sử dụng thư viện Polly gửi lại request api khi request bị lỗi hay rớt mạng
- [DEVEXPRESS] Chia sẻ source code tạo báo cáo report in tem nhãn label trên C# winform
- [DEVEXPRESS] Hướng dẫn vẽ biểu đồ Bar Chart trên Winform
- [C#] Tạo form đăng nhập và đăng ký với hiệu ứng Sliding Animation Effect
- [C#] Hướng dẫn tạo thanh toán đơn hàng qua mã vạch VietQR sử dụng API PayOS hoàn toàn miễn phí
- [C#] Hướng dẫn ghi log ra RichTextBox giống Console trên Winform sử dụng thư viện Serilog
- [C#] Hướng dẫn cách tạo mã QR Code trên file Excel
- [VB.NET] Gởi tin nhắn và file đính kèm qua ứng dụng gởi tin nhắn Whats App
- [C#] Viết ứng dụng Auto Fill list Textbox from clipboard Winform
- [TOOL] Chia sẻ phần mềm thay đổi thông tin cấu hình máy tính
- [C#] Hướng dẫn Export dữ liệu ra file Microsoft Word Template
- [C#] Chia sẻ source code tool kiểm tra domain website
- [C#] Hướng dẫn tạo file PDF sử dụng thư viện QuestPDF
[C#] Sự kiện Reactive Observable Event Winform
Xin chào các bạn, bài viết hôm nay mình sẽ hướng dẫn viết sự kiện trên Winform Event Rx.net Obserable C#.
[C#] Obserable Reactive Envent Winform
Windows Forms có sử dụng giao diện INotifyPropertyChanged, chúng ta có thể sử dụng như ví dụ dưới đây.
Source code Obserable Reactive Envent c#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
void Ticker()
{
Observable.Interval(TimeSpan.FromSeconds(1))
.ObserveOn(this)
.Subscribe(x => textBox1.Text = DateTime.Now.ToLongTimeString());
}
void WordCount()
{
var textChanged = Observable.FromEventPattern
<EventHandler, EventArgs>(
handler => handler.Invoke,
h => textBox3.TextChanged += h,
h => textBox3.TextChanged -= h);
textChanged
.ObserveOn(this)
.Subscribe(x => textBox2.Text =
textBox3.Text
.Split()
.DefaultIfEmpty()
.Count(word => !string.IsNullOrWhiteSpace(word))
.ToString());
}
private void Form1_Load(object sender, EventArgs e)
{
Ticker();
WordCount();
}
}
}
Thanks for watching!