Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. List View items - exporting and importing data

List View items - exporting and importing data

Scheduled Pinned Locked Moved C#
helptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Stanimir_Stoyanov
    wrote on last edited by
    #1

    Hi. I have a list view with about 4000 items (with 7 subitems, too) and I'd like to 'export', ie. save all the data, to a tab-separated file, so the data can be reloaded later. The problem is, that the saving and loading process using, for example: (Save) (...) foreach(ListViewItem lvi in this.listView1.Items) { string line = ""; line += lvi.Text; for(int i=1;i

    P 1 Reply Last reply
    0
    • S Stanimir_Stoyanov

      Hi. I have a list view with about 4000 items (with 7 subitems, too) and I'd like to 'export', ie. save all the data, to a tab-separated file, so the data can be reloaded later. The problem is, that the saving and loading process using, for example: (Save) (...) foreach(ListViewItem lvi in this.listView1.Items) { string line = ""; line += lvi.Text; for(int i=1;i

      P Offline
      P Offline
      Patric_J
      wrote on last edited by
      #2

      Hi, what you want to do is called serialization. Serialization is saving an object's state to a stream so its state can be transported or saved and later restored. You suggested a tab separated text file, which is nice since the file is easily read and understood by other applications, however binary files are faster. If format don't mattter to you, I would suggest binary format. BinaryFormatter.Serialize Method is the method you use for binary serialization. The problem will be for you that a listview control or ListViewItemCollection object do not support serialization. To be able to serialize an object, the object's class needs to be either marked with the Serializable attribute or implement the ISerializable interface. The class ArrayList however is marked Serializable attribute and it's pretty easy to construct an arraylist from a listview control. Good luck and feel free to check my C# blog, Patric

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups