the question are: Dubbelposta är fult http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2132218&SiteID=1Listview and .txt counter
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);
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..???
kan svara på svenska också =)
Thanks////Sv: Listview and .txt counter