• <menu id="w2i4a"></menu>
  • logo DevExpress WinForms使用教程

    文檔首頁>>DevExpress WinForms使用教程>>DevExpress Winforms使用技巧教程:v20.1中的API更改

    DevExpress Winforms使用技巧教程:v20.1中的API更改


    下載DevExpress v20.1完整版    DevExpress v20.1漢化資源獲取

    DevExpress Winforms Controls 內(nèi)置140多個(gè)UI控件和庫,完美構(gòu)建流暢、美觀且易于使用的應(yīng)用程序。想要體驗(yàn)?點(diǎn)擊下載>>

    本文包含重大的更改信息,這些更改信息可能會影響WinForms Data Editors命名控件中使用兩種未記錄方法的更改信息。

    在v20.1版本中,DoFormatEditValue和DoParseEditValue(在XtraEditors命名空間中)將不再是虛擬的,并且不再可以被覆蓋。技術(shù)團(tuán)隊(duì)更是了兩個(gè)技術(shù)示例,如果您在應(yīng)用中使用此API,建議您在決定升級到v20.1時(shí)對代碼進(jìn)行同樣的更改。

    先前的執(zhí)行:

    protected override ConvertEditValueEventArgs DoFormatEditValue(object val)
    protected override ConvertEditValueEventArgs DoParseEditValue(object val)


    當(dāng)前實(shí)施:

    protected override object DoFormatEditValue(object val, out bool handled)
    protected override object DoParseEditValue(object val, out bool handled)

    請注意,不建議您重寫這些新方法,請改用RaiseFormatEditValue和RaiseParseEditValue,這些方法引發(fā)相應(yīng)的編輯事件,不太可能再次更改。

    //version 19.2 and older
    protected override ConvertEditValueEventArgs DoFormatEditValue(object val) {
    ConvertEditValueEventArgs result = base.DoFormatEditValue(val);
    result.Value = MyFormatEditValue(result.Value);
    result.Handled = true;
    return result;
    }
    
    protected override ConvertEditValueEventArgs DoParseEditValue(object val) {
    ConvertEditValueEventArgs result = base.DoParseEditValue(val);
    result.Value = MyParseEditValue(result.Value);
    result.Handled = true;
    return result;
    }
    
    //version 20.1 and newer
    protected override void RaiseFormatEditValue(ConvertEditValueEventArgs e) {
    base.RaiseFormatEditValue(e);D
    e.Value = MyFormatEditValue(e.Value);
    e.Handled = true;
    }
    
    protected override void RaiseParseEditValue(ConvertEditValueEventArgs e) {
    base.RaiseParseEditValue(e);
    e.Value = MyParseEditValue(e.Value);
    e.Handled = true;
    }
    //Version 19.2 and older
    protected override ConvertEditValueEventArgs DoFormatEditValue(object val) {
    if(val is int) {
    switch((int)val) {
    case 0: return new ConvertEditValueEventArgs("zero");
    case 1: return new ConvertEditValueEventArgs("one");
    case 2: return new ConvertEditValueEventArgs("two");
    case 3: return new ConvertEditValueEventArgs("three");
    }
    }
    return base.DoFormatEditValue(val);
    }
    protected override ConvertEditValueEventArgs DoParseEditValue(object val) {
    if(val is string) {
    switch((string)val) {
    case "zero": return new ConvertEditValueEventArgs(0);
    case "one": return new ConvertEditValueEventArgs(1);
    case "two": return new ConvertEditValueEventArgs(2);
    case "three": return new ConvertEditValueEventArgs(3);
    }
    }
    return base.DoParseEditValue(val);
    }
    
    //Version 20.1 and newer
    protected override void RaiseFormatEditValue(ConvertEditValueEventArgs e) {
    base.RaiseFormatEditValue(e);
    if(e.Value is int) {
    e.Handled = true;
    switch((int)e.Value) {
    case 0: e.Value = "zero"; break;
    case 1: e.Value = "one"; break;
    case 2: e.Value = "two"; break;
    case 3: e.Value = "three"; break;
    }
    }
    }
    
    protected override void RaiseParseEditValue(ConvertEditValueEventArgs e) {
    base.RaiseParseEditValue(e);
    if(e.Value is string) {
    e.Handled = true;
    switch((string)e.Value) {
    case "zero": e.Value = 0; break;
    case "one": e.Value = 1; break;
    case "two": e.Value = 2; break;
    case "three": e.Value = 3; break;
    }
    }
    }

    對于IRangeControlClient的自定義實(shí)現(xiàn),您將需要用DevExpress.XtraEditors.RangeControlClientOrientation手動替換System.Windows.Forms.Orientation類型。

    對于調(diào)度程序控件,將所有出現(xiàn)的System.Windows.Forms.KeyEventArgs和System.Windows.Forms.MouseEventArgs類型替換為相應(yīng)的對應(yīng)變量:DevExpress.Portable.Input.PortableKeyEventArgs和DevExpress.Portable.Input.PortableMouseEventArgs。

    // Version 19.2 and earlier
    public class MyKeyboardHandlerService : KeyboardHandlerServiceWrapper {
    public override void OnKeyDown(KeyEventArgs e) {
    ...
    }
    }
    
    public class MyMouseHandlerService : MouseHandlerServiceWrapper {
    public override void OnMouseWheel(MouseEventArgs e) {
    ...
    }
    }
    
    // Version 20.1 and newer
    
    public class MyKeyboardHandlerService : KeyboardHandlerServiceWrapper {
    public override void OnKeyDown(PortableKeyEventArgs e) {
    ...
    }
    }
    
    public class MyMouseHandlerService : MouseHandlerServiceWrapper {
    public override void OnMouseWheel(PortableMouseEventArgs e) {
    ...
    }
    }


    中國區(qū)首發(fā) · DevExpress v20.1新版發(fā)布會報(bào)名開啟,名額有限先到先得哦~

    DevExpress技術(shù)交流群2:775869749      歡迎一起進(jìn)群討論

    掃描關(guān)注DevExpress中文網(wǎng)微信公眾號,及時(shí)獲取最新動態(tài)及最新資訊

    DevExpress中文網(wǎng)微信
    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();