0

If the BorderStyle property of many intrinsic WinForms controls, such as ListView or TreeView, is set to Fixed3D, the border of such a control is rendered using the OS visual styles (sure, if they are enabled). However, this does not work for the Panel control. Compare the ListView and Panel controls on the screenshot below:

enter image description here

Is there a trick that can cause the 3D border of the Panel control to be rendered with the visual styles? If not, what is workaround (say, using custom painting)?

TecMan
  • 2,743
  • 2
  • 30
  • 64
  • 1
    Based on your [previous question](https://stackoverflow.com/q/74044111/7444103), are you **designing** your app for VisualStyles or not? Pick one and design for that. If Users set the System to their own preferences, that's their choice -- Panels don't set the 3D Border style by default, but to `BorderStyle.None`, so someone has set a 3D border manually, probably because the app was previously designed with visual styles disabled. You can set `[Some Panel].BorderStyle = Application.RenderWithVisualStyles ? BorderStyle.FixedSingle : BorderStyle.Fixed3D;` – Jimi Oct 14 '22 at 15:59
  • @Jimi, this question is not related to the one you mentioned anyhow. As for me, it is evident that I ask about drawing TRUE OS-STYLED BORDER in the case when VISUAL STYLES ARE ENABLED in the app. FixedSingle is not the border I expect because it is a 1-pixel-width black rectangle. You must know that the OS-styled border is a 2-pixel-width rectangle in which the outer line is drawn with a grayish color and the inner line is a white one (at least, in the latest releases of the OS). – TecMan Oct 17 '22 at 08:01
  • @Jimi, you asked: "are you designing your app for VisualStyles or not?" A good developer must think about both cases. The `Fixed3D` border in all intrinsic WinForms controls behaves right automatically: the true OS-styled 2-pixel-width border is drawn when visual styles are enabled and the classic 3D border from the era of Windows 95 is drawn instead. – TecMan Oct 17 '22 at 08:05
  • The System Theme(s) apply to all Controls that support this, i.e., all Controls that have a native counterpart or are specifically designed to apply the current Theme. As a TreeView / ListView. The Panel Control is simply a *Control* (i.e., a generic Window). Both TreeView and Panel set the same exact styles in `CreateParams`, but of course the rendering can be different from System to System. This also because a Panel Control is not a visual element, it's a Container element and should be treated as such -- Your app applies Visual Styles, I don't see a reason to design for something else – Jimi Oct 18 '22 at 18:25
  • @Jimi, please, stop flooding. I asked how to solve the problem, even with custom drawing. If you do not have a solution, better write nothing. – TecMan Oct 19 '22 at 06:00

0 Answers0