zoukankan      html  css  js  c++  java
  • 【.NET开发之美】使用ComponentOne提高.NET DataMap中的加载速度

    概述

    1. FlexGrid for WinForm 采用了最新的数据绑定技术,并与Microsoft .NET Framework无缝集成。 因此,您可以获得易于使用的灵活网格控件,用于创建用户友好界面,以显示、编辑、格式化、组织、汇总和打印表格数据。

    2. FlexGrid的DataMap属性允许您实现“已翻译”的行或列。在转换的行或列中,网格不显示存储在单元格中的值。相反,它会在列的DataMap中查找这些值并显示映射的值。

    3. 有时您可能需要在C1FlexGrid / C1FlexGridClassic中使用DataMap来显示项目列表。即使列表包含大量数据,其加载也是平滑且即时的。在本文中,我们将讨论如何使用自定义ComboBox编辑器以加快DataMap网格的加载时间。

    创建编辑器并在Grid中托管它

    所有内置网格编辑器都实现IC1EmbeddedEditor接口,ComponentOne Input库中的控件也是如此。 如果我们想要使用带有C1FlexGrid的第三方编辑器,我们需要创建一个派生类并实现此接口。

    实现步骤

    创建一个模型类MyComboItem来绑定ComboBox。

    public class MyComboItem

    {
        public int Id { get; set; }
        public string Display { get; set; }
    }
    

    创建一个自定义控件MyComboBox,它继承ComboBox类并实现IC1EmbeddedEditor接口。

    public partial class MyComboBox : ComboBox, IC1EmbeddedEditor
        {
            public MyComboBox()
            {
                InitializeComponent();
            }
            #region IC1EmbeddedEditor-Members
            // Initialize editor: select transferred value
            public void C1EditorInitialize(object value, IDictionary editorAttributes)
            {
                    this.SelectedValue = value;
            }
            //Get value from editor
            public object C1EditorGetValue()
            {
                return (base.SelectedItem as MyComboItem)?.Id; 
            }
            //Value is always TRUE
            public bool C1EditorValueIsValid()
            {
                return true;
            }
            //Adjust editor size
            public void C1EditorUpdateBounds(Rectangle rc)
            {
                if (rc.Height != -1 && rc.Width != -1)
                {
                    this.Location = new Point(rc.X, rc.Y);
                    this.Width = rc.Width;
                    this.Height = this.DefaultSize.Height;
                }
                else
                {
        //Editor has scrolled out of the picture. Take over the height / width of -1.
                    this.Width = -1;
                    this.Height = -1;
                }
            }
    
            //TRUE if Escape or Enter
            public bool C1EditorKeyDownFinishEdit(KeyEventArgs e)
            {
                if (e.KeyCode == Keys.Escape || e.KeyCode == Keys.Enter)
                    return true;
                return false;
            }
    
            //Format and editor value
            public string C1EditorFormat(object value, string mask)
            {
                return null;
            }
    
           //Style of Editors
            public UITypeEditorEditStyle C1EditorGetStyle()
            {
                return UITypeEditorEditStyle.DropDown;
            }
            #endregion
        }
    }
    

    创建MyComboBox类的实例,并将其分配给网格的列编辑器,如下所示:

    Dictionary<int, string> DMap = new Dictionary<int, string>();
                ComboBox c1 = new MyComboBox();
                List<MyComboItem> _list = new List<MyComboItem>();              
                c1.DataSource = _list;
                c1.ValueMember = "Id";
                c1.DisplayMember = "Display";            
                _flex.Cols[2].Editor = c1;
               _flex.Cols[2].DataMap = DMap; //use DataMap to show IDs as values.
    

    ComponentOne Enterprise | 下载试用

    ComponentOne是一款专注于企业应用高性能开发的 .NET 全功能控件套包,包含300余种控件,支持7大平台,涵盖7大功能模块。较于市面上其他同类产品,ComponentOne更加轻盈,功能更加强大,20多年的开发经验,将为您的应用系统带来更为安全的使用体验。纯中文操作界面,一对一技术支持,厂商级的技术服务,共同造就了这款国际顶级控件套包。

    您对ComponentOne 产品的任何技术问题,都有技术支持工程师提供1对1专业解答,点击此处即可发帖提问>> 技术支持论坛

  • 相关阅读:
    解决pyinstaller 打包后运行exe程序出现的"ModuleNotFindError"
    【Tensorflow专题-03】深层神经网络
    【Tensorflow专题-02】使用tensorflow训练神经网络
    【Tensorflow专题-01】深度学习应用介绍及tensorflow基本使用
    Github 简明教程
    Composer 安装与使用
    为jQuery的$.ajax设置超时时间
    thinkphp 数据库表多字段排序
    TP5如何隐藏入口文件index.php
    Atom编辑器快捷键大全
  • 原文地址:https://www.cnblogs.com/C1SupportTeam/p/10101670.html
Copyright © 2011-2022 走看看