setting radio box to transparent!

dec21st

Active member
Joined
May 14, 2005
Messages
43
Programming Experience
3-5
i've attached the img below as how the interface is

--see attached jpeg before continuing. thanks

i've tried setting my back color to transparent but it doesn't seem to work. The other labels (Year of Manufacture and etc.) are set to transparent and it seem to work out fine.

i suspect it's the use of Infragistics component in my project

my radiobox, (in this case the convention is set to option set) is declared in a class like the following

VB.NET:
Option Explicit On 
Option Strict On

Public Class XRadioButton
	Inherits System.Windows.Forms.RadioButton

#Region " Windows Form Designer generated code "

	Public Sub New()
		MyBase.New()

		'This call is required by the Windows Form Designer.
		InitializeComponent()

		'Add any initialization after the InitializeComponent() call
	End Sub

	'Form overrides dispose to clean up the component list.
	Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
		If disposing Then
			If Not (components Is Nothing) Then
				components.Dispose()
			End If
		End If
		MyBase.Dispose(disposing)
	End Sub

	'Required by the Windows Form Designer
	Private components As System.ComponentModel.IContainer

	'NOTE: The following procedure is required by the Windows Form Designer
	'It can be modified using the Windows Form Designer.  
	'Do not modify it using the code editor.
	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
		components = New System.ComponentModel.Container
	End Sub
#End Region

End Class

and the declaration to create the radio button is the following in any form

VB.NET:
Me.optNew = New [edited].XRadioButton
'
'
'
Me.optNew.BackColor = System.Drawing.Color.Transparent
Me.optNew.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, _
   System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.optNew.Location = New System.Drawing.Point(472, 23)
Me.optNew.Name = "optNew"
Me.optNew.Size = New System.Drawing.Size(72, 24)
Me.optNew.TabIndex = 8
Me.optNew.Text = "New"


any solution??
 

Attachments

  • error1.JPG
    error1.JPG
    14.3 KB · Views: 104
that should work but apparently it doesnt (as shown in the picture)

try changing the radiobutton's background color to transparent in the form's Load event
 
i've tried changing it on the Form Load event
i've even tried testing on the click event but all doesn't seem to work

it doesn't invoke the event at all.. not too sure why
 
[Rant]
Kulrom, I've finally downloaded one of your apps and I must ask: what's the purpose of this one?
With the standard radioButton, all that needs to be done to have a transparent backGround is to set that in the property explorer. In your Form's load event, you set the radioButton's Parent property to Me. Care to explain why you do this.

“Give a man a fish; you have fed him for today. Teach a man to fish; and you have fed him for a lifetime”
[/Rant]

Anywho, It seems that the Infragistics component doesn't support transparent backgrounds, but I don't own those components to be sure.
 
Well, pazst thanks for the question ... actually i also suspected a problem with the component and that's why i told him to Set Style of the form to support transparent color. Moreover, i thought he has set up the form's background as bitmap and since the form's image is set to a bitmap, he cannot see the form's background and that's why his RBs stay colored Maybe it wasn't case but it was most logical on first sight. Also note that to make the control's background transparent, you can set the alpha blend value of their background to zero.

RadioButton1.BackColor = Color.FromArgb(0, RadioButton1.BackColor )
'or as i already said use the System.Drawing.Color.Transparent color




Cheers ;)

Not all of us use a design view to deal with control's properties :D
 
Last edited:
Protected Overrides Sub OnPaint(ByVal pe As PaintEventArgs)
Dim g As Graphics = pe.Graphics
Dim rect As Rectangle = New Rectangle(0, 0, 300, 300)
Dim lBrush As LinearGradientBrush = New LinearGradientBrush(rect, Color.Red, Color.Yellow, LinearGradientMode.BackwardDiagonal)
g.FillRectangle(lBrush, rect)
End Sub
-----------------
if we don't put it in out form , ur code wont work !!!! i want to reduce of backcolor or remove backcolor of radio button !!! , i cn't do ittt !!! i load a picture on my form but radio button's back color doesn't let to see the picture clearly !! pls help me someone !!!
 
Back
Top