- [C#] Hướng dẫn viết ứng dụng theo dõi máy in bao nhiêu trang (Monitor Printer)
- [C#] Lấy thông tin cấu hình máy tính xuất ra text file winform
- [C#] Chia sẽ class Install, Uninstall, Start và Stop Services Winform
- [C#] Tìm kiếm tập tin file nhanh chóng trên Winform sử dụng thư viện FastSearchLibrary
- [C#] Giới thiệu thư viện Fluent FTP Awesome dùng để làm việc với FTP
- [C#] Sử dụng thư viện Mini Profiler Integrations ghi log thực hiện các câu lệnh SQL
- [DEVEXPRESS] Thiết kế Dropdown ButtonBarItem trên Form Ribbon
- [C#] Lưu trạng thái các control trên Winform vào Registry Windows
- [C#] Ứng dụng ví dụ Simple Observer Pattern tăng giảm số lượng trên winform
- [C#] Hướng dẫn lấy thời gian thực server time trên winform
- [DEVEXPRESS] Hướng dẫn bật tính năng Scroll Pixcel in Touch trên GridView
- [DEVEXPRESS] Hướng dẫn sử dụng TileBar viết ứng dụng duyệt hình ảnh Winform
- [DEVEXPRESS] Tô màu border TextEdit trên Winform
- [C#] Lấy dữ liệu từ Console Write hiển thị lên textbox Winform
- [C#] Hiển thị Progress bar trên Window Console
- [C#] Di chuyển control Runtime và lưu layout trên winform
- [SQLSERVER] Sử dụng hàm NULL IF
- [C#] Chia sẽ source code mã đi tuần bằng giao diện Winform
- [C#] Flash Window in Taskbar Winform
- Download và Giải nén tập tin File sử dụng Powershell
[DEVEXPRESS] Hướng dẫn sử dụng Unbound Column trên GridView C#
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 sử dụng Unbound Column trên Gridview Devexpress C# winform.
[DEVEXPRESS] USING UNBOUND COLUMN GRIDVIEW C#
Ví dụ: các bạn theo dõi hình ảnh demo dưới đây.
Khi thiết lập đơn hàng hay xuất hàng, các bạn sẽ có 2 cột dữ liệu: Quantity
và Price
(số lương và đơn giá)
Còn thành tiền, thì mình sẽ không có lưu dưới cơ sở dữ liệu database.
Vậy khi hiển thị mình mong muốn hiển thị thêm cột Thành Tiền tự động được tính bằng Số lượng * Đơn giá.
Thì ở Column Total Money: các bạn không điền filedname, và setup Unbound column như hình dưới đây.
Do kiểu Total Money nên mình chọn là kiểu Decimal nhé.
Hoặc bạn có thể chỉnh Unbound column runtime ở đây:
Full source code Unbound Column 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;
namespace unBoundColumn
{
public partial class Form1 : DevExpress.XtraEditors.XtraForm
{
public Form1()
{
InitializeComponent();
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
var table = new DataTable();
table.Columns.Add("ID", typeof(int));
table.Columns.Add("Name", typeof(string));
table.Columns.Add("Quantity", typeof(decimal));
table.Columns.Add("Price", typeof(decimal));
table.Rows.Add(1, "Apple", 5, 12.5);
table.Rows.Add(1, "Banana", 8, 5.25);
table.Rows.Add(1, "Tomato", 3, 4.23);
table.Rows.Add(1, "Oranges", 7, 15.28);
table.Rows.Add(1, "Lemon", 15, 12.36);
table.Rows.Add(1, "Water Lemon", 23, 9.63);
table.Rows.Add(1, "Cherry", 9, 7.5);
table.Rows.Add(1, "Coconuts", 18, 20.1);
table.Rows.Add(1, "Kiwi", 2, 15.23);
gridControl1.DataSource = table;
}
private void btn_expression_Click(object sender, EventArgs e)
{
gridView1.ShowUnboundExpressionEditor(colTotalMoney);
}
private void labelControl1_Click(object sender, EventArgs e)
{
}
}
}
Happy coding :)