How to reset to default button BackColor?

后端 未结 11 1776
失恋的感觉
失恋的感觉 2020-12-13 23:38

I was experimenting with different options for the button background color and ended up changing the BackColor property in the Appearance category. I then chang

相关标签:
11条回答
  • 2020-12-14 00:33

    Referring to your question title, "How to reset to default button BackColor?" , I solved my problem by:

    Create another button, say ButtonFoo, and set it to invisible,

    ButtonFoo.visible = False
    

    and you can use this button to get its color (since it is a default color) to reset your another button color, for example,

    ButtonChangedColor.BackColor = ButtonFoo.BackColor
    

    There you go; color is restored to its default :)

    0 讨论(0)
  • 2020-12-14 00:36
    Button1.BackColor = Color.FromKnownColor(KnownColor.Control)
    

    Use the FromKnowColor to access the system colors. It is really that simple.

    0 讨论(0)
  • 2020-12-14 00:41

    What worked for me:

    CommandButton1.BackColor = vbButtonFace
    
    0 讨论(0)
  • 2020-12-14 00:42

    In Winforms the default color is Control. You can set it from the Properties Pane in VS.

    PropertyName is BackColor and the color you want is in System Colors -> Control

    0 讨论(0)
  • 2020-12-14 00:43

    To restore the default background and foreground to a button use:

    Button1.BackColor = SystemColors.ButtonFace;
    Button1.ForeColor = default(Color);
    Button1.UseVisualStyleBackColor = true;
    
    0 讨论(0)
提交回复
热议问题