简体   繁体   中英

Button color totally transparent

So I have image in button but my problem is default color of button. I changed back color of button to color of my panel but I still have border around it, is there a way to remove it so entire button color would be transparent and only image would be visible ?

button1.FlatStyle = FlatStyle.Flat;
button1.FlatAppearance.BorderSize = 0;
button1.FlatAppearance.BorderColor = //Set your Background color here

By default, controls do not support transparent backcolors. However, you can allow your control to have a background color that is opaque, transparent, or partially transparent by using the Control.SetStyle Method in the constructor. The SetStyle method of the Control class allows you to set particular style preferences for your controls, and can be used to enable or disable support for transparent backcolors.

To give your control a transparent backcolor

  • In the Code Editor for your control, locate the constructor.
  • Call the SetStyle method of your form in the constructor.

    SetStyle(ControlStyles.SupportsTransparentBackColor, true);

This will enable your control to support a transparent backcolor.

  • Beneath the line of code you added in step 1, add the following line. This will set your control's BackColor to Transparent.

    this.BackColor = Color.Transparent;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM