Click here to Skip to main content
12,763,360 members (29,706 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#

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);
                itemName.SubItems.Add(itemSize.ToString() + " Kb");

public ListViewItem getSize(string eachFile)
            FileInfo f = new FileInfo(eachFile);
            long fileSize = f.Length;
            ListViewItem FileSize = new ListViewItem(fileSize.ToString());
            return FileSize;
Posted 24-Jan-13 4:57am
Updated 24-Jan-13 5:35am
Kishor Deshpande 24-Jan-13 9:59am
Code please..
DaedalusAero 24-Jan-13 10:36am
Please see revised question above for code. Thanks in advance.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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");
Will print
ListViewItem: {hello}
I assume that you have removed a class which derived from ListViewItem, and which overrode ToString to produce the output you wanted.
DaedalusAero 24-Jan-13 10:49am
Many thanks. I had managed to break it by fiddling - that pointed me in the right direction. Thanks again.
OriginalGriff 24-Jan-13 10:55am
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 24 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100