tags:

views:

214

answers:

2

As the title goes. I already implemented this in listbox. now i want to implement this to listview with multiple columns. can you also include drawcolumnheader example?

+1  A: 

ListView (in winforms) is tied to the win32 control. If you want more flexibility, I would switch to DataGridView; this still lets you display tabular data, but you can change the styling at various levels of granularity.

Marc Gravell
+1  A: 

If you are just getting started with a ListView, do yourself a favor and have a look at ObjectListView. ObjectListView is an open source wrapper around .NET WinForms ListView, which makes it much easier to use, as well as easily allowing things that are very difficult in a normal ListView.

Changing the backcolor of the selected item is an example of something that is difficult in a normal ListView but easy with an ObjectListView. In a normal ListView, the background of selected rows is controlled by the system -- you cannot change it to anything else. But with an ObjectListView, you just do this:

this.objectListView1.OwnerDraw = true;
this.objectListView1.HighlightBackgroundColor= Color.Red;

Also, out of the box, the ObjectListView allows you to change the font and text color of the column header. You can even word wrap the column header if you want:

alt text

Grammarian