Click here to Skip to main content
15,919,245 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the data I need to load only available from the data reader

In my normal listView i do
C#
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 });
 }


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 !
Posted
Updated 17-Aug-11 22:02pm
v3

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>


and try that link with advanced options :
Link1
regards..
 
Share this answer
 
Comments
Dalek Dave 18-Aug-11 4:09am    
Good Answer, 5.
I have no idea what you just suggested ?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900