实际的单词“ListViewItem:”出现在我的ListView列中 [英] The actual words 'ListViewItem:' appearing in my ListView columns
问题描述
有人可以告诉我为什么我得到的单词ListViewItem:{ data here }in我的ListView SubItem列。换句话说,当我运行我的Win Forms应用程序时,在我的ListView的每一列中,我有数据的子项,实际的单词''ListViewItem ... ''出现在数据本身之前 - 用大括号显示。
直到我整理一些代码才发生这种情况。我希望这是一个简单的错误。
这是调用我的方法的代码。方法(或部分)显示在下面。
Hi,
Can anybody please tell me why i''m getting the words "ListViewItem: {data here}" in my ListView SubItem columns. In other words when i run my Win Forms application, in each column of my ListView where i have subItems of data, the actual words ''ListViewItem ...'' are appearing just before the data itself - which is displayed in curly braces.
This wasn''t happening until i was tidying some code up. I''m hoping it''s a simple mistake.
Here is the code which calls my method. And the method (or part of) is shown underneath.
// ListView1
string[] checkedINfileList = Directory.GetFiles("O:\\TestDaws\\CSDB\\CheckedIN");
foreach (string file in checkedINfileList)
{
ListViewItem itemName = list1.getName(file);
ListViewItem itemSize = list1.getSize(file);
ListViewItem itemModified = list1.getDate(file);
listView1.Items.Add(itemName);
itemName.SubItems.Add(itemSize.ToString() + " Kb");
itemName.SubItems.Add(itemModified.ToString());
public ListViewItem getSize(string eachFile)
{
FileInfo f = new FileInfo(eachFile);
long fileSize = f.Length;
ListViewItem FileSize = new ListViewItem(fileSize.ToString());
return FileSize;
推荐答案
因为这就是ListViewItem的默认ToString重写:打印类名为ListViewItem的后跟冒号,然后是大括号中的数据内容。
Because that is what the default ToString overridde of ListViewItem does: Prints the name ofg the class "ListViewItem" followed by a colon, and then the data content in curly brackets.
ListViewItem lvi = new ListViewItem("hello");
Console.WriteLine(lvi);
将打印
Will print
ListViewItem: {hello}
我假设您已删除了一个类派生自ListViewItem,并覆盖ToString以产生您想要的输出。
I assume that you have removed a class which derived from ListViewItem, and which overrode ToString to produce the output you wanted.
这篇关于实际的单词“ListViewItem:”出现在我的ListView列中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!