Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6348319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:23:45+00:00 2026-05-24T21:23:45+00:00

Microsoft’s visual styles for winforms have always befuddled me. I am trying to have

  • 0

Microsoft’s visual styles for winforms have always befuddled me.

I am trying to have a Panel sit next to a TreeView and just have the same VisualStyle border.

Border Colors

As you can see, the TreeView border is different than my drawing attempts in my Panel. The panel’s BorderStyle is set to None.

I’ve tried this:

  Rectangle r = new Rectangle(0, 0, panel1.ClientRectangle.Width - 1, panel1.ClientRectangle.Height - 1);
  using (Pen p = new Pen(VisualStyleInformation.TextControlBorder))
    e.Graphics.DrawRectangle(p, r);

and I’ve tried this:

VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.TextBox.TextEdit.Normal);
renderer.DrawEdge(e.Graphics, panel1.ClientRectangle, 
         Edges.Bottom | Edges.Left | Edges.Right | Edges.Top,
         EdgeStyle.Sunken, EdgeEffects.Flat);

Any suggestions for the correct visual border color or visual element to use?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:23:47+00:00Added an answer on May 24, 2026 at 9:23 pm

    This issue isn’t limited to WinForms… Since the WinForms TreeView control is simply a wrapper around the native Win32 TreeView control, it’s drawing the same border style as a TreeView control would anywhere else in the system, such as Windows Explorer. And as you’ve observed, the 3D border style looks different with visual styles enabled than it did on previous versions of Windows. It actually doesn’t look 3D at all—the effect is closer if you set the border to Single/FixedSingle, except that it’s a little too dark compared to the one around the TreeView.

    As far as how to replicate that for a Panel control, I think the trick lies not in drawing an edge, but rather in drawing a background.

    There might be a more elegant solution if you P/Invoke the DrawThemeBackground function directly along with some of the Parts and States that aren’t exposed in the .NET VisualStyleRenderer wrapper, but this one looks pretty good to me:

    VisualStyleRenderer renderer =
                  new VisualStyleRenderer(VisualStyleElement.Tab.Pane.Normal);
    renderer.DrawBackground(e.Graphics, panel1.ClientRectangle);
    

       

       (The TreeView is on the left; the Panel is on the right.)


    If you want to draw the border yourself and match the colors used when visual styles are enabled, you can do that, too. This would simply be a matter of determining the correct color, and then using the standard GDI+ drawing routines to draw a line or two around the control.

    But don’t fire up Photoshop just yet! The colors are all documented in a file named AeroStyle.xml, located in the include folder of the Windows SDK. You’re interested in the globals values; these:

    <globals>
        <EdgeDkShadowColor> 100 100 100</EdgeDkShadowColor>
        <EdgeFillColor>     220 220 220</EdgeFillColor>
        <EdgeHighLightColor>244 247 252</EdgeHighLightColor>
        <EdgeLightColor>    180 180 180</EdgeLightColor>
        <EdgeShadowColor>   180 180 180</EdgeShadowColor>
        <GlowColor>         255 255 255</GlowColor>
    </globals>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Microsoft Visual Studio (2005 and 2008) seems to have fun shuffling the Project IDs
Microsoft make this piece of software called Visual Studio 2008 Professional. I have found
Microsoft is planning to make Windows 8 an 128-bit operating system. I have always
Microsoft Visual Studio Unable to start program 'theprogram.exe'. This application has failed to start
Microsoft release a product named - Visual Studio Load Test Virtual User Pack 2010
Microsoft Visual C# 2010 Express I've been looking all day for a way to
Microsoft's WebMatrix development tool has a Visual Studio button to launch the VS editor
Microsoft have recently released a Bing maps objective c component. See here and here
Microsoft have explained that they won't be supporting Edit and Continue under the x64
Microsoft has just launched a new search engine, Bing, Bing Is Not Google. Does

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.