Winform with BlackTheme

ravi poddar 11 Reputation points
2023-03-08T18:41:38.5533333+00:00

Hi,

How I set black theme in Winform and over all its child control at runtime

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,436 questions
{count} vote

2 answers

Sort by: Most helpful
  1. Michael Taylor 48,976 Reputation points
    2023-03-08T19:05:40.4433333+00:00

    Winforms does not support theming of any sort. Winforms is a thin layer over the Win32 API and will follow the theme of Windows. If you want theming support in Winforms your only real option is to use a third party library but even then it isn't great and there will be gaps. This is just the way it is with Winforms.

    If you don't want to go that route then you'll need to define a "theme" based upon what you want to change, create the structures to support it and then at runtime swap out the colors based upon the theme you are using. Of course there are things you won't be able to change and you still cannot change things that managed by Windows such as the chrome around the main window and message box styling. You can see a sample article that someone wrote here. I cannot confirm or deny how good the solution is.

    If you aren't tied to Winforms then WPF/XAML supports theming.

    1 person found this answer helpful.

  2. Sander van de Velde 29,456 Reputation points MVP
    2023-03-08T23:34:01.5166667+00:00

    Hello @ravi poddar ,

    the answer from @Michael Taylor tells exactly what is going on with how Winform works.

    Your question is not unique and there are discussions for future support.

    You can of course start yourself by deriving new controls yourself with the closest (background/border) color property settings as you can imagine.

    Still, this can take a lot of time.

    Look around on NuGet for already available dark-themed control libraries.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.

    0 comments No comments