Click here to Skip to main content
6,822,123 members and growing! (18,007 online)
Email Password   helpLost your password?
Desktop Development » Miscellaneous » Beginners     Beginner License: The Code Project Open License (CPOL)

Visual Style Element Browser

By jkristia

A simple tree which exposes the different VisualStyleElements available in NET 2.0
C# (C#2.0, C#3.0), Windows
Posted:10 Feb 2008
Updated:12 Feb 2008
Views:15,085
Bookmarked:49 times
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
14 votes for this article.
Popularity: 5.12 Rating: 4.47 out of 5
1 vote, 7.1%
1

2
1 vote, 7.1%
3
2 votes, 14.3%
4
10 votes, 71.4%
5
VisualElementBrowser

Introduction

I wrote this small utility app while working on the custom 'tree with columns' control, which you can see used in this same app. There is really not much to it, but I figured it might be useful for others working on custom controls.

A VisualStyleElement is a UI element exposed by the system and can be used by any custom control to draw a system control or element. In the case of the tree control, the visual element is used to draw the column and row headers.

More information regarding the visual styles can be found in System.Windows.Forms.VisualStyles namespace and here.

The only part that was a little tricky was to populate the tree. All elements are defined as nested static classes within VisualStyleElement (check it out with Reflector). After a little bit of trial and error I found it to be quite simple though, get the nested types and for each type get the static properties, and do this recursive. The code for this is in VisulalStyleTreeV1.AddType(type).

To paint the style in the tree, I created a derived class of CellPainter and overwrote PaintCell for the Style column (fieldname called image for this column !?)

And that is all.

Revision History

  • 2/12/2008: V1 uploaded
    A workaround fix for the hanging issue when running release. I don't understand why it would go into an infinite loop when run in release (but not when run in release from debugger), but the issue was resolved by moving 2 variables out of the CompareColorByBrightness method.

License

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

About the Author

jkristia


Member

Occupation: Software Developer (Senior)
Location: United States United States

Other popular Miscellaneous articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 4 of 4 (Total in Forum: 4) (Refresh)FirstPrevNext
GeneralNice Pinmembernorm .net11:06 12 Feb '08  
GeneralBug report PinmemberDreamwolf1:33 12 Feb '08  
GeneralRe: Bug report Pinmemberjkristia4:19 12 Feb '08  
GeneralRe: Bug report Pinmemberjkristia8:03 12 Feb '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads.

PermaLink | Privacy | Terms of Use
Last Updated: 12 Feb 2008
Editor: Deeksha Shenoy
Copyright 2008 by jkristia
Everything else Copyright © CodeProject, 1999-2010
Web09 | Advertise on the Code Project