- [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
- [C#] Hướng dẫn cách lấy thông tin đăng nhập tài khoản và mật khẩu web browser trên windows
- [VB.NET] CRUD Thêm xóa sửa tìm kiếm Realtime FireBase
- [C#] Hiển thị thông báo Toast Message trong lập trình Winform
- [C#] Cấu hình định dạng ngày tháng, thời gian trên Windows cho ứng dụng Winform
- [C#] Rút gọn đường dẫn link url với TinyURL API
- [C#] Hướng dẫn cách bo tròn winform with Radius
- [C#] Chia sẽ class BackGroundOverlay Show Modal cho Winform
- [C#] Hướng dẫn Flip Image Winform
- [C#] Invoke là gì? cách sử dụng phương thức Invoke()
- [C#] Hướng dẫn chia sẽ file, folder từ ứng dụng sang Zalo Chat
[DEVEXPRESS] Hướng dẫn custom màu chữ, nền, disabled CheckedComboboxEdit C#
Xin chào các bạn, bài viết hôm nay mình hướng dẫn các bạn cách format chữ và định dạng trong component CheckedComboboxEdit của Devexpress C#.
[DEVEXPRESS] Định dạng chữ, Disabled, Enabled component CheckedComboboxEdit của Devexpress C#.
Trong bài viết này, mình ví dụ các bạn có một danh sách các sản phẩm.
Và nó bao gồm ba trạng thái: Disabled
, Enabled
và Locked
.
Nếu ở mỗi trạng thái chúng ta sẽ hiển thị chúng ở CheckedComboxEdit khác nhau.
Ví dụ:
- Ở tình trạng Disabled thì chúng ta chỉ hiển thị mà không cho người dùng check vào.
- Ở tình trạng Enabled và Lock thì chúng ta sẽ hiển thị theo định dạng riêng của mình, dưới dạng HTML
Giao diện demo ứng dụng Custom CheckedComboboxEdit C#:
Source code C# Combobox Edit:
using DevExpress.Utils.Win;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraEditors.Popup;
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 Custome_CheckBoxEdit_Devexpress
{
public partial class Form1 : DevExpress.XtraEditors.XtraForm
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
var data = new[] {
new { Status = "Enabled", Value = 1, Display = "Helium" },
new { Status = "Enabled", Value = 2, Display = "Hydrogen"},
new { Status = "Enabled", Value = 3, Display = "Oxygen" },
new { Status = "Disabled", Value = 4, Display = "Argon"},
new { Status = "Lock", Value = 5, Display = "Iron"},
new { Status = "Enabled", Value = 6, Display = "Lithium"},
new { Status = "Lock", Value = 7, Display = "Copper"},
new { Status = "Lock", Value = 8, Display = "Gold"},
new { Status = "Disabled", Value = 9, Display = "Silver" },
new { Status = "Enabled", Value = 10, Display = "Uranium"},
new { Status = "Disabled", Value = 11, Display = "Plutonium"},
new { Status = "Enabled", Value = 12, Display = "Americium"},
new { Status = "Lock", Value = 13, Display = "Radon" }
};
checkedComboBoxEdit1.Properties.AllowHtmlDraw = DevExpress.Utils.DefaultBoolean.True;
checkedComboBoxEdit1.Properties.DataSource = data;
checkedComboBoxEdit1.Properties.ValueMember = "Status";
checkedComboBoxEdit1.Properties.DisplayMember = "Display";
}
private void checkedComboBoxEdit1_Popup(object sender, EventArgs e)
{
CheckedPopupContainerForm f = (sender as IPopupControl).PopupWindow as CheckedPopupContainerForm;
CheckedListBoxControl listBox = f.ActiveControl as CheckedListBoxControl;
foreach (CheckedListBoxItem item in listBox.Items)
{
item.Enabled = item.Value.ToString() != "Disabled";
if (item.Value.ToString() == "Lock")
{
item.Description = $"<size=12><color=red><s><b>{item.Description}</b></s></color></size>";
} else if(item.Value.ToString() == "Disabled")
{
item.Description = $"<size=12><color=gray><u><b>{item.Description}</b></u></color></size>";
}
else
{
item.Description = $"<size=12><backcolor=lime><color=white><b>{item.Description}</b></color></backcolor></size>";
}
}
}
}
}
Thanks for watching!