Update: Please note I have an update to this post available here.
Standard windows forms tree and listview controls look rather dated on Vista, with a blue background to indicate a selected node or item
It is very easy to update both these controls to have the vista look and feel with three lines of code by calling the SetWindowsTheme method. This is ignored on XP so adding this code will not affect the same application running on XP.
public partial class Form1 : Form
SetWindowTheme(treeView1.Handle, “explorer”, null);
SetWindowTheme(listView1.Handle, “explorer”, null);
[DllImport(“uxtheme.dll”, CharSet = CharSet.Unicode, ExactSpelling = true)]
private static extern int SetWindowTheme(IntPtr hWnd, string appName, string partList);
private void Form1_Load(object sender, EventArgs e)
Public Class Form1
<DllImport(“uxtheme.dll”, CharSet:=CharSet.Unicode, ExactSpelling:=True)> _
Private Shared Function SetWindowTheme(ByVal hWnd As IntPtr, ByVal appName As String, ByVal partList As String) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SetWindowTheme(treeView1.Handle, “explorer”, Nothing)
SetWindowTheme(listView1.Handle, “explorer”, Nothing)
3 thoughts on “Vista Treeview and Listview”
My name is Ricardo Boaro, I work for http://WWW.MRBOOL.COM as a technical editor. I would like to invite you to join our team of video classes producers.
Currently we need speakers (producers) for Java, .Net, Asp.Net and Delphi videos, but we are accepting suggestions if you know any other language.
Let me explain how it works
• Each video class must have at least fifteen minutes .
• The program that we use to record the video classes is Camtasia Studio.
• The payment for each video class sent, approved and published is US$ 80,00 (eighty dollars)
• The payment is done until the fifteenth day of the next month after the publishing
• THE PAYMENT IS POSSIBLE PAY TO YOU FOR THIS FORM PAYPAL
We would be pleased if you join our team. If you have any question or doubt, just get in touch with me.
My e-mail firstname.lastname@example.org
Pingback: Disabling windows themes for controls « Castalian
Pingback: Windows 7 TreeView and ListView « Castalian