Search code examples
vb.netwinformstelerik

i'm trying to make d background color of a radpanel ( using telerik) transluscent


i have tried using this code below but it doesnt seem to work:

Public Class TransparentPanel
      Inherits Panel
      Protected Overrides ReadOnly Property CreateParams() As CreateParams
      Get
        Dim cp As CreateParams = MyBase.CreateParams
        cp.ExStyle = cp.ExStyle Or &H20
        ' WS_EX_TRANSPARENT
        Return cp
      End Get
End Property

Protected Overrides Sub OnPaint(e As PaintEventArgs)
    e.Graphics.FillRectangle(New SolidBrush(Me.BackColor), Me.ClientRectangle)
End Sub
End Class

'======================================================= 'Service provided by Telerik (www.telerik.com) 'Conversion powered by NRefactory. 'Twitter: @telerik 'Facebook: facebook.com/telerik '=======================================================

Here is my code :

Imports Telerik.WinControls

Public Class Form1


  Private Sub Button1_Click(sender As System.Object, e As System.EventArgs)    Handles Button1.Click

      '' RadPanel1.BackColor = Color.Red
       RadPanel1.Visible = True
    RadPanel1.AutoSize = True
    RadPanel1.RootElement.StretchVertically = True
    RadPanel1.RootElement.StretchHorizontally = True
    RadPanel1.Location = New Point(2, 2)
    RadPanel1.Size = New Size(200, 1)
    RadPanel1.Text = "I am RadPanel"

    Dim setting As New AnimatedPropertySetting()
    setting.[Property] = RadElement.BoundsProperty
    setting.StartValue = New Rectangle(0, 0, 200, 1)
    setting.EndValue = New Rectangle(0, 0, 280, 250)
    setting.Interval = 30
    setting.NumFrames = 35
    setting.ApplyValue(RadPanel1.RootElement)
End Sub


End Class

Solution

  • When working with transparency in WinForms you should have in mind that a control can be transparent only compared to its parent control. Therefore, you will be able to observe RadPanel transparency compared to the Form, if the Form is its parent. However, if you have two RadPanels, both children to the Form, but not children to each other, you will not see transparency in the place where they overlap each other.

    Here are some articles on the matter: