温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何使用ComponentOne提高.NET DataMap中的加载速度

发布时间:2021-11-30 17:01:57 来源:亿速云 阅读:174 作者:小新 栏目:编程语言

这篇文章主要介绍了如何使用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提高.NET DataMap中的加载速度”这篇文章对大家有帮助,同时也希望大家多多支持亿速云,关注亿速云行业资讯频道,更多相关知识等着你来学习!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI