Chỉnh sửa thông báo DevExpress (XtraMessageBox)

Đăng bởi : 6/17/2014

thuvienwinform - Mình rất là không thích những đoạn mà xen lấn tiếng anh, tiếng việt. Điển hình là các thông báo. Mặc định các nút đề là tiếng anh(OK, Yes, No, Cancel,...) chúng ta nên việt hóa toàn bộ. Vừa dễ dàng cho người sử dụng, vừa có được giao diện đẹp.



Công việc này khá đơn giản. Tạo 1 lớp (class) là xong!
Chú ý: cần thêm DevExpress.Data; và DevExpress.XtraEditors; (Add Reference)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.XtraEditors.Controls;
using DevExpress.Utils.Localization;

namespace ThuVienWinform.ThongBaoDevExpress
{
    //https://documentation.devexpress.com/#WindowsForms/CustomDocument1866
    public class TuyChinhDevExpress : Localizer
    {
        public string Abort { set; get; }
        public string Cancel { set; get; }
        public string Ignore { set; get; }
        public string No { set; get; }
        public string Ok { set; get; }
        public string Retry { set; get; }
        public string Yes { set; get; }

        public TuyChinhDevExpress(string abort, string cancel, string ignore, string no, string ok, string retry, string yes)
        {
            this.Abort = abort;
            this.Cancel = cancel;
            this.Ignore = ignore;
            this.No = no;
            this.Ok = ok;
            this.Retry = retry;
            this.Yes = yes;
        }

        public override string GetLocalizedString(StringId id)
        {
            if (id == StringId.XtraMessageBoxAbortButtonText) return this.Abort;
            if (id == StringId.XtraMessageBoxCancelButtonText) return this.Cancel;
            if (id == StringId.XtraMessageBoxIgnoreButtonText) return this.Ignore;
            if (id == StringId.XtraMessageBoxNoButtonText) return this.No;
            if (id == StringId.XtraMessageBoxOkButtonText) return this.Ok;
            if (id == StringId.XtraMessageBoxRetryButtonText) return this.Retry;
            if (id == StringId.XtraMessageBoxYesButtonText) return this.Yes;
            return base.GetLocalizedString(id);
        }
    }
}

Sử dụng:
Khai báo đoạn này trong sự kiện nạp (Form_load), hay trong tệp Program.cs đều được:
Chú ý: using DevExpress.XtraEditors.Controls;

Localizer.Active = new TuyChinhDevExpress("&Hủy bỏ", "&Hủy", "&Chấp nhận", "&Xác nhận", "&Được", "&Thử lại", "&Được");

Vậy là xong rồi!


Bình luận

Theo dõi các bài đăng | Theo dõi bài này

Nhận ngay 100$ cho VPS

Mua hàng ủng hộ page

Ủng hộ page

Nhãn

Code (45) Team Foundation Server (17) Database (14) News (14) product (13) toolbox (10) Linq (9) SoftDesign (8) XNA (6) API (5) Project (5) item (4)

- Bản quyền thuộc về Thư Viện WinForm - Giao diện: Metrominimalist - Thiết kế: Johanes Djogan -