0

I have an application in which I have used radio button over an image so it seems very bad with white background in radio button.

enter image description here

So is there a way I can remove that white background ?

Vishal Suthar
  • 17,013
  • 3
  • 59
  • 105
  • If you care about `UI` it may be worth to create a custom `RadioButton` which will also looks *fancy* (not as ugly as standard one). It can support transparency from the box. – Sinatr Nov 07 '14 at 14:24

3 Answers3

2

Only setting the BackColor to Color.Transparent is not enough to get rid of the little border that is around the RadioButton.

What you will need to also do is call the following code for each radio button to ensure that the background does actually go transparent

rbnTest.BackColor = Color.Transparent;
Point pos = this.PointToScreen(rbnTest.Location);
rbnTest.Parent = pibPicture;
rbnTest.Location = pibPicture.PointToClient(pos);

Source (Not a true duplicate, but similar, hence not flaggin as duplicate)

I would recommend refactoring that code into a reusable method so that you do not scatter the code all over your project.

Community
  • 1
  • 1
Bernd Linde
  • 2,098
  • 2
  • 16
  • 22
1

Locate the constructor for your control class. The constructor appears in the control's code file. In C#, the constructor is the method with the same name as the control and with no return value.

Call the SetStyle method of your form in the constructor.

SetStyle(ControlStyles.SupportsTransparentBackColor, true);

add the following line. This will set your control's BackColor to Transparent.

this.BackColor = Color.Transparent;

Note Windows Forms controls do not support true transparency. The background of a transparent Windows Forms control is painted by its parent.

MMM
  • 3,132
  • 3
  • 20
  • 32
-1

You can use the RadioButton.BackgroundImage or the RadioButton.BackColor property. Choose the one that suits you best

dimlucas
  • 5,040
  • 7
  • 37
  • 54
  • Can you specify which `BackColor` I have to set to achieve this ? – Vishal Suthar Nov 07 '14 at 13:39
  • A serious question? Maybe... purple for a skin-colored picture in the back? Have you tried setting transparent? If this isnt working, I would say you should guess the best color for yourself. Its your project. – C4d Nov 07 '14 at 13:42
  • Yeah. I agree, setting the background color to transparent seems to be your best option – dimlucas Nov 07 '14 at 13:44