如何从FastObjectListView添加数据 [英] How to add data fro FastObjectListView

查看:261
本文介绍了如何从FastObjectListView添加数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要加载的数据只能从数据读取器中获得

在我的普通listView中,我会做

I have the data I need to load only available from the data reader

In my normal listView i do

while (myReaderData.Read())
 {
 ListViewItem lvi = new ListViewItem(myReaderData.GetValue(0).ToString());
 for (int x = 1; x <= Rows - 1; x++)
 {
 lvi.SubItems.Add(myReaderData.GetValue(x).ToString());
 }
 BrowseView.Items.AddRange(new ListViewItem[] { lvi });
 }



原因是我的数据每次都不同.我可以动态设置数组或数据视图并使用它吗?
如果可以,怎么办?

如何将数据加载到FastObjectListView中?

任何人都请!



The reason for this is that my data is different every time. Can I set up an array or dataview dynamiclly and use that ?
If so how ?

How would I load the data into a FastObjectListView ?

Anyone please !

推荐答案

您好:

你可以这样:

Hello :

you can do like that :

public override void AddObjects(ICollection modelObjects)
      {
          foreach (object modelObject in modelObjects) {
              if (modelObject != null)
                  this.objectList.Add(modelObject);
          }
          this.RebuildIndexMap();
      }

      public override void RemoveObjects(ICollection modelObjects)
      {
          List<int> indicesToRemove = new List<int>();
          foreach (object modelObject in modelObjects) {
              int i = this.GetObjectIndex(modelObject);
              if (i >= 0)
                  indicesToRemove.Add(i);
          }
          // Sort the indices from highest to lowest so that we
          // remove latter ones before earlier ones. In this way, the
          // indices of the rows doesn''t change after the deletes.
          indicesToRemove.Sort();
          indicesToRemove.Reverse();

          foreach (int i in indicesToRemove)
              this.listView.SelectedIndices.Remove(i);

          foreach (int i in indicesToRemove)
              this.objectList.RemoveAt(i);

          this.RebuildIndexMap();
      }

      public override void SetObjects(IEnumerable collection)
      {
          ArrayList newObjects = new ArrayList();
          if (collection != null) {
              if (collection is ICollection)
                  newObjects = new ArrayList((ICollection)collection);
              else {
                  foreach (object x in collection)
                      newObjects.Add(x);
              }
          }

          this.objectList = newObjects;
          this.RebuildIndexMap();
      }

      private ArrayList objectList = new ArrayList();</int></int>



并尝试使用高级选项进行链接:
链接1
问候..



and try that link with advanced options :
Link1
regards..


我不知道您刚才提出了什么建议?
I have no idea what you just suggested ?


这篇关于如何从FastObjectListView添加数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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