I am trying to write to only one column of a listView (a subitem) but I want it so I can run two arrays through it not just one array.
When I try to do that it adds it to the next column in the listView (not the one i want it to write to).
For example this adds the array to different columns, not all of them to the same one:
string[] k = getBetweenAll(thepage, "<h4 style=\"padding:0 0 0 3px;\"><a href=\"", "\" target=\"_blank\">");
string[] q = getBetweenAll(thepage, "<h4><a href=\"", "\" target=\"_blank\">");
for (int i = 0; i < k.Length && i < listViewClickbank.Items.Count; i++)
{
listViewClickbank.Items[i].SubItems.Add(input + k[i]);
listViewClickbank.Items[i].SubItems.Add(input + q[i]);
}
从您的问题中尚不清楚确切的结果是什么,但是如果要将两个值连接在一起成为一行的一列,请执行以下操作:
listViewClickbank.Items[i].SubItems.Add(input + k[i] + q[i]);
Concatenate the two arrays before adding them to the listview.
var z = new string[k.Length + q.Length];
k.CopyTo(z, 0);
q.CopyTo(z, k.Length);
//TODO: Add z to the listview
Or you can do it without concatenation
for (int i = 0; i < k.Length + q.Length; i++)
{
if (i < k.Length) {
Items.SubItems.Add(input + k[i]);
} else {
Items.SubItems.Add(input + q[i - k.Length]);
}
}
Try this:
string[] k = getBetweenAll(thepage, "<h4 style=\"padding:0 0 0 3px;\"><a href=\"", "\" target=\"_blank\">");
string[] q = getBetweenAll(thepage, "<h4><a href=\"", "\" target=\"_blank\">");
var items = listViewClickbank.Items;
var z = new int[k.Length + q.Length];
k.CopyTo(z, 0);
q.CopyTo(z, k.Length);
for (int i = 0; i < z.Length; i++)
{
Items.SubItems.Add(input + z[i]);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.