在C#.NET 4.0慢数据绑定设置时间 [英] Slow Databinding setup time in C# .NET 4.0

查看:133
本文介绍了在C#.NET 4.0慢数据绑定设置时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题。我有Windows窗体动态生成的布局应用程序,但我已经在性能上的问题。在这种形式下,我使用数据绑定 .NET 4.0 后绑定设置工作正常,但他结合设置时间< STRONG> ONE 控制在约挡住了我的应用程序的0.7秒。我有一些控制和暴饮暴食setuping的时间是围绕 2的分

I have got a problem. I have windows forms application with dynamic generated layout, but i have a problem in performance. In this form i use DataBinding from .NET 4.0 and databinding after setup works fine, but he binding setup time for ONE control blocking my application on approx 0.7 second. I have some controls and time of binging setuping is around 2 minutes.

我尝试所有可能的解决方案,我没有写没有自我约束力类的任何想法。
为什么错我的代码

I trying all possible solutions, I dont have any ideas without write self binding class. Why is wrong with my code?

case "Boolean":
{
    Binding b = new Binding("Checked", __bindingsource, __ep.Name);
    CheckBox cb = new CheckBox();

    /*
     * HERE is the start of problem
     */

    cb.DataBindings.Add(b);

    /*
     * HERE is the end of problem
     */

    __flp.Controls.Add(cb);
    __bindingcontrol.AddBinding(b);
    break;
}



没有问题的代码行一切工作快速,无约束力;-(但我想在正常速度结合转变。

Without problem code lines all works fast and without binding ;-( but i want binding turn on in normal speed.

PS1。在生成时间我已经暂停布局。

PS1. I have suspended layout in generation time.

PS2。我有同样的问题结合TextBox'es,PictureBoxe的,复选框唯一的例子。

PS2. I have same problem with binding TextBox'es, PictureBoxe's, CheckBox is only example.

怎么做以上littley如何调试的问题,VS2010探查只说问题是绑定,我知道这一点。

How to do that or more littley how to debug the problem, the vs2010 profiler says only the problem is the Binding and i know that.


  1. System.Windows.Forms.Control.ControlCollection.Add(类System.Windows.Forms。控制)

  2. System.Windows.Forms.ControlBindingsCollection.Add(类System.Windows.Forms.Binding)

编辑:的DataContext从数据库(实体框架)

推荐答案

这工作。并不快,因为 __的BindingSource 有很多的元素。绑定不工作好大的集合,这是一个问题。

This working not fast because __bindingsource have many elements. Binding not working good with big collections and this is a problem.

__的BindingSource 的BindingSource 类。而且必须有快速的工作要少得多元素。我解决了这个问题,每个创建另一个新的的BindingSource 实例 BindingSet 的(我的意思是绑定一次性多元素一个对象的属性)只有一个元素仅这是我要用的。

__bindingsource is a BindingSource class. And must have much less elements to fast working. I solved this problem with creating another new BindingSource instance for each BindingSet (I mean Binding onetime much elements to properties of one object) with only one element, only this what i want to use.

这篇关于在C#.NET 4.0慢数据绑定设置时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆