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. Help please! About Listview and .txt file

Help please! About Listview and .txt file

Scheduled Pinned Locked Moved C#
questiondatabaseregexhelptutorial
1 Posts 1 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

    the question are: i add this into a listview string ett = "1"; string u = comboBox1.Text; string q = textBox1.Text; string w = textBox2.Text; DateTime dt = DateTime.Now; if (q.Length > 0 && w.Length > 0 && u.Length > 0) { if (this != null) { string time = dt.ToString("dd"); string name = this.textBox1.Text + time.ToString() + ett; ListViewItem item = new ListViewItem(new string[] { u, name, dt.ToString(), this.textBox2.Text }); ListViewIns.Items.Add(item); But string u and name can not be equal with something else in a .txt file for example string u = Online name = k431121 And the .txt file look like this: # online k431121 blah blah If they two string match with line[index +1] an line[index +2] then add +1 on k431121. So in this example they match it will add +1 and look like this # online k431121 blah blah # online k431122 blah blah I have a code but it don´t want to work: private List Entries; private void LoadEntries() { string key; Entries=new List(); foreach (ListViewItem item in listView1.Items) { key = string.Concat(item.SubItems[0], "@@", item.SubItems[1]); if (!Entries.Contains(key)) Entries.Add(key); } } private void PopulateListView(List list) { LoadEntries(); listView1.View = View.Details; listView1.Columns.Add("Kolumn1"); listView1.Columns.Add("Kolumn2"); listView1.Columns.Add("Kolumn3"); listView1.Columns.Add("Kolumn4"); listView1.Columns.Add("Kolumn5"); string Name,No,key; int n; for (int i = 0; i < list.Count; i += 5) { Name = list[i+1]; No = list[i + 2]; while(Entries.Contains(key = string.Concat(Name, "@@", No))) { n = Convert.ToInt32(No.Substring(No.Length - 1)); No = String.Concat(No.Substring(0, No.Length - 1), n + 1); } if (!Entries.Contains(key)) Entries.Add(key); ListViewItem item = new ListViewItem(list[i]); item.SubItems.Add(Name); item.SubItems.Add(No); item.SubItems.Add(list[i + 3]); item.SubItems.Add(list[i + 4]); listView1.Items.Add(item); } } My question is: can you help me build this together..???:sigh: :):-D:laugh: Thanks////

    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