Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hello friends,
I am using something like below but I am encountering some problem.
If I change the liste[k] with any Listview object without array is ok..

A.Text = split[0] + " / " + split[2];
                     A.SubItems.Add(split[4]);
                     A.SubItems.Add(split[8]);
                     A.SubItems.Add(split[12]);
                     A.Items.Add(liste[k]);

this codes are working but if I use listview array it doesn't work.

What I have tried:

<pre lang="c#">

<pre>                if (year >= year1 && year <= year2)
                    if (month >= month1 && month <= month2)
                        if (day >= day1 && day <= day2)
                        {
                         
                            richTextBox1.AppendText(s[k] + "\n");

                            liste[k].Text = split[0] + " / " + split[2];
                            liste[k].SubItems.Add(split[4]);
                            liste[k].SubItems.Add(split[8]);
                            liste[k].SubItems.Add(split[12]);
                            listView2.Items.Add(liste[k]);

                        }
                
            }
            //listView2.Items.Add(liste[0]);
           // listView2.Items.AddRange(liste);
Posted
Updated 14-May-18 8:57am
Comments
[no name] 14-May-18 7:45am    
Code snippet you added does not seems to be completed and do say anything on issue you are facing. Elaborate pls
Emrah Duatepe 14-May-18 7:54am    
Codes are here,I am trying to access with order in text.My real problem here is liste

private void Read_File(int year1, int month1, int day1, int year2, int month2, int day2)
{

int i = -1, day, month, year;
listView1.Items.Clear();
string str="";
string[] s = new string[100];
string[] split, split1;
//sr.Close();
sr = File.OpenText(filePath);
//StreamReader sr = new StreamReader(filePath);
//str = sr.ReadLine();
//richTextBox1.AppendText(str);
// richTextBox1.Text = str;


do
{
i++;
s[i] = sr.ReadLine();
} while (s[i] != null);
sr.Close();



for (int k = 0; k < i-1; k++)
{
str = "";
split = s[k].Split(' ');

for (int j = 0; j < split.Length; j++)
{
str = str + split[j];
}

split = str.Split('_'); //*****//

split1 = split[0].Split(':');

day = Int32.Parse(split1[0]);
month = Int32.Parse(split1[1]);
year = Int32.Parse(split1[2]);


if (year >= year1 && year <= year2)
if (month >= month1 && month <= month2)
if (day >= day1 && day <= day2)
{

richTextBox1.AppendText(s[k] + "\n");
liste[k].Text = split[0] + " / " + split[2];
liste[k].SubItems.Add(split[4]);
liste[k].SubItems.Add(split[8]);
liste[k].SubItems.Add(split[12]);
listView2.Items.Add(liste[k]);

}

}
//listView2.Items.Add(liste[0]);
//listView2.Items.AddRange(liste);


}
Patrice T 14-May-18 18:50pm    
Use Improve question to update your question.
So that everyone can pay attention to this information.

1 solution

Please follow this code ...
C#
ColumnHeader columnHeader1=new ColumnHeader();
columnHeader1.Text="Column1";
this.listView1.Columns.AddRange(new ColumnHeader[] { columnHeader1 });
ListViewItem item = new ListViewItem("1");
this.listView1.Items.Add(item);
this.listView1.View = View.Details;
 
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