<small id='l6UuQ'></small><noframes id='l6UuQ'>

    • <bdo id='l6UuQ'></bdo><ul id='l6UuQ'></ul>

        <tfoot id='l6UuQ'></tfoot>
        <legend id='l6UuQ'><style id='l6UuQ'><dir id='l6UuQ'><q id='l6UuQ'></q></dir></style></legend>
      1. <i id='l6UuQ'><tr id='l6UuQ'><dt id='l6UuQ'><q id='l6UuQ'><span id='l6UuQ'><b id='l6UuQ'><form id='l6UuQ'><ins id='l6UuQ'></ins><ul id='l6UuQ'></ul><sub id='l6UuQ'></sub></form><legend id='l6UuQ'></legend><bdo id='l6UuQ'><pre id='l6UuQ'><center id='l6UuQ'></center></pre></bdo></b><th id='l6UuQ'></th></span></q></dt></tr></i><div id='l6UuQ'><tfoot id='l6UuQ'></tfoot><dl id='l6UuQ'><fieldset id='l6UuQ'></fieldset></dl></div>

        使用 BindingSource 很慢?

        Using BindingSource is very slow?(使用 BindingSource 很慢?)
      2. <legend id='jd26v'><style id='jd26v'><dir id='jd26v'><q id='jd26v'></q></dir></style></legend>

            <small id='jd26v'></small><noframes id='jd26v'>

                <bdo id='jd26v'></bdo><ul id='jd26v'></ul>
                    <tbody id='jd26v'></tbody>
                1. <tfoot id='jd26v'></tfoot>
                2. <i id='jd26v'><tr id='jd26v'><dt id='jd26v'><q id='jd26v'><span id='jd26v'><b id='jd26v'><form id='jd26v'><ins id='jd26v'></ins><ul id='jd26v'></ul><sub id='jd26v'></sub></form><legend id='jd26v'></legend><bdo id='jd26v'><pre id='jd26v'><center id='jd26v'></center></pre></bdo></b><th id='jd26v'></th></span></q></dt></tr></i><div id='jd26v'><tfoot id='jd26v'></tfoot><dl id='jd26v'><fieldset id='jd26v'></fieldset></dl></div>
                  本文介绍了使用 BindingSource 很慢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 C# Windows 窗体项目,其中包含一个包含 2 个列表框和一个按钮的窗体.在 FormLoad 上,左侧 ListBox 填充了一个列表(大约 1800 项),其中包含有关证券(ID 和名称)的信息,当用户单击该按钮时,所有证券都会从左侧列表框移到右侧.

                  I have a C# Windows Forms project with a Form containing 2 ListBoxes and a button. On FormLoad the left ListBox is filled with a list (about 1800 items) containing information about Securities (ID and Name) and when the user clicks on the button all the securities are moved from the left listbox to the right.

                  当我不使用 BindingSources 时,即我直接使用 ListBoxes 的 Items 属性时,移动过程需要几秒钟:

                  When I'm not using BindingSources, i.e. I'm directly using the Items property of the ListBoxes the moving process takes a few seconds:

                  private void button1_Click(object sender, EventArgs e)
                  {
                      while (listBox1.Items.Count > 0)
                      {
                           Security s = listBox1.Items[0] as Security;
                           listBox1.Items.Remove(s);
                           listBox2.Items.Add(s);
                      }
                  }
                  

                  但是,当我使用 BindingSources 时,它需要几分钟:

                  But, when I'm using BindingSources it takes several minutes:

                  listBox1.DataSource = bindingSource1;
                  listBox2.DataSource = bindingSource2;
                  
                  ...
                  
                  private void MainForm_Load(object sender, EventArgs e)
                  {
                      ICollection<Security> securities = GetSecurities();
                      bindingSource1.DataSouce = securities;
                  }
                  
                  private void button1_Click(object sender, EventArgs e)
                  {
                      while (bindingSource1.Count > 0)
                      {
                          bindingSource1.Remove(s);
                          bindingSource2.Add(s);
                      }
                  }
                  

                  BindingSource 方式需要这么长时间的原因是什么?有什么办法让它更快?

                  What's the reason for the BindingSource-way to take so much longer? Is there any way to make it faster?

                  推荐答案

                  好的,解决了.我必须操作底层集合,然后在最后重置绑定.现在它几乎立即移动:)

                  Ok, solved it. I have to manipulate the underlying collection and then reset bindings at the end. Now it's almost instantly moving :)

                  这篇关于使用 BindingSource 很慢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Populate ListBox with a IEnumrable on another thread (winforms)(在另一个线程(winforms)上使用 IEnumrable 填充 ListBox)
                  listbox selected item give me quot; System.Data.DataRowViewquot; , C# winforms(列表框选择的项目给我quot;System.Data.DataRowView, C# Winforms)
                  Cannot remove items from ListBox(无法从列表框中删除项目)
                  Preventing ListBox scrolling to top when updated(更新时防止列表框滚动到顶部)
                  Deselection on a WPF listbox with extended selection mode(具有扩展选择模式的 WPF 列表框上的取消选择)
                  How do I get at the listbox item#39;s quot;keyquot; in c# winforms app?(如何获取列表框项目的“键?在 c# winforms 应用程序中?)

                    <i id='693V3'><tr id='693V3'><dt id='693V3'><q id='693V3'><span id='693V3'><b id='693V3'><form id='693V3'><ins id='693V3'></ins><ul id='693V3'></ul><sub id='693V3'></sub></form><legend id='693V3'></legend><bdo id='693V3'><pre id='693V3'><center id='693V3'></center></pre></bdo></b><th id='693V3'></th></span></q></dt></tr></i><div id='693V3'><tfoot id='693V3'></tfoot><dl id='693V3'><fieldset id='693V3'></fieldset></dl></div>

                    <small id='693V3'></small><noframes id='693V3'>

                    1. <legend id='693V3'><style id='693V3'><dir id='693V3'><q id='693V3'></q></dir></style></legend>

                          <tbody id='693V3'></tbody>
                          • <bdo id='693V3'></bdo><ul id='693V3'></ul>
                          • <tfoot id='693V3'></tfoot>