- [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#] Show Modal Winform like Bootstrap
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 tạo hiệu ứng show Modal Effect giống Boottrap Website.
[C#] Show Modal Dialog Effect Like Bootstrap Winform
Dưới đây, video demo ứng dụng:
Source code FormMain.cs:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace modal
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public static int parentX, parentY;
        private void button1_Click(object sender, EventArgs e)
        {
            Form modalBackground = new Form();
            using (modalForm modal = new modalForm(this)) {
                modalBackground.StartPosition = FormStartPosition.Manual;
                modalBackground.FormBorderStyle = FormBorderStyle.None;
                modalBackground.Opacity = .50d;
                modalBackground.BackColor = Color.Black;
                modalBackground.Size = this.Size;
                modalBackground.Location = this.Location;
                modalBackground.ShowInTaskbar = false;
                modalBackground.Show();
                modal.Owner = modalBackground;
                parentX = this.Location.X;
                parentY = this.Location.Y;
                modal.ShowDialog();
                modalBackground.Dispose();
            }
        }
    }
}
Source code FormModal.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace modal
{
    public partial class modalForm : Form
    {
        public Form _parent;
        public modalForm(Form parent)
        {
            InitializeComponent();
            this._parent = parent;
            
        }
        public bool isShow = true;
        private void modalEffect_Timer_Tick(object sender, EventArgs e)
        {
            if (isShow)
            {
                if (Opacity >= 1)
                {
                    modalEffect_Timer.Stop();
                }
                else
                {
                    Opacity += .04;
                }
                int y = Form1.parentY += 6; //INCREMENT
                this.Location = new Point(childFormX, y);
                if (y >= i)
                {
                    modalEffect_Timer.Stop();
                }
            }
            else {
                if (Opacity <= 0)
                {
                    modalEffect_Timer.Stop();
                    this.Close();
                }
                else
                {
                    Opacity -= .04;
                }
                int y = Form1.parentY -= 6; //DECREMENT
                this.Location = new Point(childFormX, y);
                if (y == i)
                {
                    modalEffect_Timer.Stop();
                    this.Close();
                }
            }
        }
        int i, childFormX, childFormY;
        private void button2_Click(object sender, EventArgs e)
        {
            button1_Click(sender, e);   
        }
        private void modalForm_Load(object sender, EventArgs e)
        {
            int parentFormX = _parent.Location.X;
            int parentFormY = _parent.Location.Y;
            childFormX = parentFormX + (_parent.Width - this.Width) / 2;
            childFormY = parentFormY + (_parent.Height - this.Height) / 2;
            i = childFormY;
            this.Location = new Point(childFormX, childFormY);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            i = 0;
            isShow = false;
            modalEffect_Timer.Start();
           //this.Close();
        }
    }
}
Thanks for watching!

![[C#] Show Modal Winform like Bootstrap](https://laptrinhvb.net/uploads/users/9a8cb514e4428e85fb4ca07588e9103f.png)

![[C#] Hướng dẫn Thêm, xóa, sửa với PostgreSQL winform](https://laptrinhvb.net/uploads/source/new_image_baiviet/screenshot_1686208193.png)

![[C#] Hook Right context menu windows (ex: Pin and Unpin Taskbar)](https://laptrinhvb.net/uploads/source/csharp/pin_unpin_taskbar_thumb.jpg)

![[C#] Hướng dẫn thay đổi giao diện ứng dụng Winform theo giao diện của Windows](https://laptrinhvb.net/uploads/source/new_image_baiviet/CHANGE_THEME_THUMB.png)
![[C#] Hướng dẫn tạo textbox tạo mã sản phẩm trên winform](https://laptrinhvb.net/uploads/source/vbnet/code_product_csharp.png)
![[C#] Viết ứng dụng Screen Saver đơn giản trong Winform](https://laptrinhvb.net/uploads/source/csharp/screen_saver_thumb.gif)
![[C#] Hướng dẫn đọc trực tiếp file Excel đang mở C#](https://laptrinhvb.net/uploads/source/csharp/read_excel_thumb.jpg)
![[C#] Hướng dẫn lấy thông tin Your ID và Password của Ultraviewer Winform](https://laptrinhvb.net/uploads/source/vbnet/ultraviewer_pass_id.jpg)

![[C#] Chia sẽ thư viện MCoreLib.dll để lập trình AT Command gởi, nhận tin nhắn SMS  và các chức năng khác](https://laptrinhvb.net/uploads/source/csharp/sms_lib_csharp.jpg)
![[C#] Hướng dẫn convert HTML code sang PDF File trên NetCore 7 Winform](https://laptrinhvb.net/uploads/source/new_image_baiviet/HTML_TO_PDF_NETCORE.png)
![[C#] Cách tính độ tương phản màu sắc Contrast Color mà con người có thể nhìn thấy được](https://laptrinhvb.net/uploads/source/new_image_baiviet/hight_contract_color_thumb.png)

![[C#] Hướng dẫn bắt sự kiện khi đối tượng di chuyển chạm vào object trên winform HitTest Object](https://laptrinhvb.net/uploads/source/new_image_baiviet/hitTest_object.gif)
![[C#] Kiểm tra đường dẫn website có tồn tại hay không?](https://laptrinhvb.net/uploads/source/csharp/check_url_exists_thumb.jpg)
![[C#] Mã hóa và giải mã Data Protection API trên winform](https://laptrinhvb.net/uploads/source/new_image_baiviet/DPAPI_encrypt_decrypt.png)
![[C#] LINQ trong CSharp - Phần hai](https://laptrinhvb.net/uploads/source/image_baiviet/70d122114e7e0e5dd5f474d05c4653b5.jpg)
![[C#] Hướng dẫn viết ứng dụng tự động thực hiện cuộc gọi fb (Call Video Facebook Messager)](https://laptrinhvb.net/uploads/source/csharp/call_facebook_thumb.jpg)

![[C#] Hướng dẫn thay đổi màu sắc và kích thước hình ảnh SVG trong lập trình csharp](https://laptrinhvb.net/uploads/source/csharp/svg_thumb1.jpg)
![[C#] Chia sẻ source code tạo hiệu ứng pixel Image trên winform](https://laptrinhvb.net/uploads/source/new_image_baiviet/effect_pixel_image_thumb.png)
![[C#] Hướng dẫn viết addin Excel Lấy hình ảnh từ URL internet vào Excel](https://laptrinhvb.net/uploads/source/new_image_baiviet/addin_excel.png)
![[C#] Hướng dẫn đọc file hình ảnh định dạng WEBP và chuyển đổi WebP sang JPG](https://laptrinhvb.net/uploads/source/new_image_baiviet/webp_csharp.png)
![[C#] Hướng dẫn mã hóa file cấu hình App.config trong winform](https://laptrinhvb.net/uploads/source/csharp/app_config_thumb.jpg)
