我有来自XML的数据:
var searched = from c in xml.Descendants("tbody").Descendants("tr")
let team = c.Element("td").ElementsAfterSelf("td")
select new Time
{
a = c.Element("td").ElementsAfterSelf("td").First().Value,
b = Int32.Parse(c.Descendants("td").ElementAt(3).Value),
c = Int32.Parse(c.Descendants("td").ElementAt(4).Value),
d = Int32.Parse(c.Descendants("td").ElementAt(5).Value),
e = Int32.Parse(c.Descendants("td").ElementAt(6).Value),
f = Int32.Parse(c.Descendants("td").ElementAt(7).Value),
g = Int32.Parse(c.Descendants("td").ElementAt(8).Value),
h = Int32.Parse(c.Descendants("td").ElementAt(9).Value),
i = Int32.Parse(c.Descendants("td").ElementAt(10).Value),
j = float.Parse(c.Descendants("td").ElementAt(11).Value)
};
Done this, I m showing them in a ListBox
:
foreach (var item in searched)
{
listBox1.Items.Add(item.a + " " + item.b + " " + item.c + " " +
item.d + " " + item.e + " " + item.f + " " + item.g + " " +
item.h + " " + item.i + " " + item.j);
listBox1.Items.Add(" ");
}
It prints fine, that s how I wanted it. Now I need to format it. Now, it is printing like this:
a b c d e f g h j
However, the variable s content differs in size. So the information do not get very organized.
So I wanted something like:
a|b|c|d|e|f|g|h|j
a|b|c|d|e|f|g|h|j
In which the | represents a column. I was thinking about a grid inside a list box but then I got lost on how to do it.