Search code examples
c#-4.0listviewiconsmarginpadding

C# ListView Image/Icon margin/padding


Is it possible to reproduce what is on the picture below in ListView, padding/margin icon to the right.

http://img801.imageshack.us/img801/4043/listview.png

My first question here, so I couldnt post the picture here.

Basically I need to move the ListView icon more right, I am reproducing file/directory browser, so the fails that are in a directory need to be below them and slighty right like in the picture, I have everything else figured out.


Solution

  • You should be using a TreeView control:
    http://msdn.microsoft.com/en-us/library/1dtsdfkx.aspx

    But if you insist on hacking a ListView to render this way, you'll simply have to take over drawing each row yourself. You can do so using the OwnerDraw property, though be warned that there's a lot of corner cases here so you should do a lot of reading to see what people have had to deal with when implementing this:
    http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.ownerdraw.aspx