Make background transparent

Below is an image of a toggle button on top of a gradient panel. Is it possible to make the background ( the white portion outside of the toggle border in the image ) transparent?



3 Replies 1 reply marked as answer

AI Anirudhan Iyyappan Syncfusion Team June 23, 2020 11:27 AM UTC

  
Hi George Bushy, 

Thank you for contacting Syncfusion support. 

We checked your query “Make background transparent” with our sample, but unfortunately we are unable to replicate this issue in our side. For further references please refer to the below sample and screenshot for further references. 

 
Screenshot: 

 

If we have misunderstood any of your query. Please let us know and share some more information based on your requirement like how you have customized your toggle button, which theme is applied for toggle button and you current version of Syncfusion Dll’s or please modify the above sample in such a way that issue replicates, which will be helpful for us to let you know a solution ASAP. 
 
Regards, 
Anirudhan 



GB George Busby June 23, 2020 10:46 PM UTC

Use the code below. The toggle button is using the BackColor of the panel to set it's back color. But if you have a gradient it does not work. In the example below I set the panels backcolor to green , then created a gradient that uses blue and black. You will see the green background around the toggle button.

using Syncfusion.Windows.Forms.Tools;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ToggleButton
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            GradientPanel gradientPanel = new GradientPanel();
            Syncfusion.Windows.Forms.Tools.ToggleButton toggleButton = new Syncfusion.Windows.Forms.Tools.ToggleButton();
            gradientPanel.Height = 100;
            gradientPanel.Width = 200;
            gradientPanel.Location=new Point(100, 100);
            gradientPanel.BackColor = Color.LightBlue;
            toggleButton.Name = "toggleButton1";
            toggleButton.Size = new System.Drawing.Size(100, 40);
            toggleButton.Location = new Point(50, 40);
            toggleButton.ThemeName = "Office2016Colorful";         
            gradientPanel.Border3DStyle = System.Windows.Forms.Border3DStyle.Flat;
            gradientPanel.BorderColor = System.Drawing.Color.Transparent;
            gradientPanel.Controls.Add(toggleButton);
            this.Controls.Add(gradientPanel);

            GradientPanel gradientPanel2 = new GradientPanel();
            Syncfusion.Windows.Forms.Tools.ToggleButton toggleButton2 = new Syncfusion.Windows.Forms.Tools.ToggleButton();
            gradientPanel2.Height = 100;
            gradientPanel2.Width = 200;
            gradientPanel2.Location = new Point(100, 300);
            gradientPanel2.BackColor = Color.Green;
            toggleButton2.Name = "toggleButton1";
            toggleButton2.Size = new System.Drawing.Size(100, 40);
            toggleButton2.Location = new Point(50, 20);
            toggleButton2.ThemeName = "Office2016Colorful";
            gradientPanel2.BackgroundColor = new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.Vertical, new System.Drawing.Color[] {
                 System.Drawing.SystemColors.HotTrack,
                 System.Drawing.SystemColors.WindowText,
                 System.Drawing.SystemColors.HotTrack});

            gradientPanel2.Border3DStyle = System.Windows.Forms.Border3DStyle.Flat;
            gradientPanel2.BorderColor = System.Drawing.Color.Transparent;
            gradientPanel2.Controls.Add(toggleButton2);
            this.Controls.Add(gradientPanel2);
        }
    }
}



DV Duraimurugan Vedagiri Syncfusion Team June 24, 2020 04:43 PM UTC

Hi George,

Thanks for your update.

We have checked the reported query "ToggleButton background appears with improperly while set the gradient style" and confirmed it is defect. We have logged defect report on this and the fix will be included in our upcoming Vol2 Sp1 release which will expected to roll out on end of July, 2020..

You can track the status through the following feedback link:

https://www.syncfusion.com/feedback/15524/togglebutton-background-appears-with-improperly-while-set-the-gradient-style

Regards,
Duraimurugan V


Marked as answer
Loader.
Up arrow icon