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. Difficult question

Difficult question

Scheduled Pinned Locked Moved C#
questioncareer
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.
  • A Offline
    A Offline
    andredani
    wrote on last edited by
    #1

    Dictionary list = new Dictionary(); String nameAndJob, Job, line, name; Int32 pages; ListViewItem item1; foreach (ListViewItem lvi in listView2.Items) { nameAndJob = string.Concat(lvi.SubItems[0].Text); if (!list.ContainsKey(nameAndJob)) list.Add(nameAndJob, lvi); Job = string.Concat(lvi.SubItems[1].Text); if (!list.ContainsKey(Job)) list.Add(Job, lvi); } using (StreamReader sr = new StreamReader(path1 + "/personalpr.txt")) { while (sr.Peek() > 0) { line = sr.ReadLine(); if (line == "#") { name = sr.ReadLine(); nameAndJob = string.Concat(name); Job = string.Concat(name); if (list.ContainsKey(nameAndJob)) { item1 = list[nameAndJob]; item1 = list[Job]; item1.SubItems[1].Text = sr.ReadLine(); item1.SubItems[3].Text = sr.ReadLine(); item1.SubItems[5].Text = sr.ReadLine(); } int result = 0; foreach (ListViewItem lvi in listView2.Items) { result += int.Parse(lvi.SubItems[2].ToString()) - int.Parse(lvi.SubItems[3].ToString()); ????????????????????:mad: ////I want to calculate lvi.subitems[2] - lvi.subitems[3] and pass the result to subitems[3].:mad: } item1.SubItems[3] = result.ToString();???????:mad: } } } } Can i delete this readline from .txt file after this use??? and how?? Thanks all!! :):-D;):laugh:

    P 1 Reply Last reply
    0
    • A andredani

      Dictionary list = new Dictionary(); String nameAndJob, Job, line, name; Int32 pages; ListViewItem item1; foreach (ListViewItem lvi in listView2.Items) { nameAndJob = string.Concat(lvi.SubItems[0].Text); if (!list.ContainsKey(nameAndJob)) list.Add(nameAndJob, lvi); Job = string.Concat(lvi.SubItems[1].Text); if (!list.ContainsKey(Job)) list.Add(Job, lvi); } using (StreamReader sr = new StreamReader(path1 + "/personalpr.txt")) { while (sr.Peek() > 0) { line = sr.ReadLine(); if (line == "#") { name = sr.ReadLine(); nameAndJob = string.Concat(name); Job = string.Concat(name); if (list.ContainsKey(nameAndJob)) { item1 = list[nameAndJob]; item1 = list[Job]; item1.SubItems[1].Text = sr.ReadLine(); item1.SubItems[3].Text = sr.ReadLine(); item1.SubItems[5].Text = sr.ReadLine(); } int result = 0; foreach (ListViewItem lvi in listView2.Items) { result += int.Parse(lvi.SubItems[2].ToString()) - int.Parse(lvi.SubItems[3].ToString()); ????????????????????:mad: ////I want to calculate lvi.subitems[2] - lvi.subitems[3] and pass the result to subitems[3].:mad: } item1.SubItems[3] = result.ToString();???????:mad: } } } } Can i delete this readline from .txt file after this use??? and how?? Thanks all!! :):-D;):laugh:

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

      As you are reading the input file, you should generate a corresponding output file. Copy only the data you want to keep from the input file to the output file. When you have finished reading the input file, overwrite it with the output file. aul

      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