When choosing a color in the properties window in visual studio, there is the possibility to choose from so called System Colors. An example for this is the color 'Window', which is the default for a textbox.
Now, I tried to set the BackColor of a Textbox programmatically back to this system color 'Window'. Turned out not to be as easy as I thought it would be.
I tried things like Color.? ... I hoped to find the color in this namespace, or even a System subsection for the systemcolors. Nothing to be found however.
Nor was there any namespace like System.Color to be found.
But how can these system colors be set from C# code than?
Well, one way turned to be using this command:
System.Drawing.Color.FromKnownColor(KnownColor.Window)
And, as you'd expect, the KnownColor enumeration contains all of the other user-definable colors.
Or even an easier method to achieve this is
System.Drawing.SystemColors.Window
Geen opmerkingen:
Een reactie posten