This is a migrated thread and some comments may be shown as answers.

RadMenuItem (backcolor)

2 Answers 70 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Bryan Brannon
Top achievements
Rank 2
Bryan Brannon asked on 30 Jan 2008, 05:08 PM
I would like to know how to programatically change the backcolor of a RadMenu Item that I am adding to a RadDropDownButton:

Private Sub LoadColors()  
        Me.ddlPatientColor.Items.Add(Me.CreateMenuItem("Red""Red"))  
        Me.ddlPatientColor.Items.Add(Me.CreateMenuItem("Green""Green"))  
        Me.ddlPatientColor.Items.Add(Me.CreateMenuItem("Blue""Blue"))  
        Me.ddlPatientColor.Items.Add(Me.CreateMenuItem("Purple""Purple"))  
        Me.ddlPatientColor.Items.Add(Me.CreateMenuItem("Black""Black"))  
        Me.ddlPatientColor.Items.Add(Me.CreateMenuItem("Brown""Brown"))  
        Me.ddlPatientColor.Items.Add(Me.CreateMenuItem("Orange""Orange"))  
        Me.ddlPatientColor.Items.Add(Me.CreateMenuItem("Yellow""Yellow"))  
        Me.ddlPatientColor.Items.Add(Me.CreateMenuItem("Pink""Pink"))  
    End Sub 
 
    Private Function CreateMenuItem(ByVal Text As StringByVal Value As StringAs RadMenuItem  
        Dim RadMenuItem As RadMenuItem = New RadMenuItem()  
        RadMenuItem.Name = Value  
        RadMenuItem.Text = Text  
        RadMenuItem.BackColor = Color.FromName(Value)  
        RadMenuItem.Font = New System.Drawing.Font("Arial", 20.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))  
        RadMenuItem.TextAlignment = ContentAlignment.MiddleLeft  
        RadMenuItem.AutoSize = False 
        RadMenuItem.Size = New System.Drawing.Size(243, 41)  
        AddHandler RadMenuItem.Click, AddressOf ColorChosen  
        Return RadMenuItem  
    End Function 

2 Answers, 1 is accepted

Sort by
0
Bryan Brannon
Top achievements
Rank 2
answered on 30 Jan 2008, 05:10 PM
Forgot to mention: ddlPatientColor is a RadDropDownButton control:

Friend
WithEvents ddlPatientColor As Telerik.WinControls.UI.RadDropDownButton

0
Jack
Telerik team
answered on 31 Jan 2008, 06:15 PM
Hello Bryan,

Thank you for writing us.

You can change the background color of the RadMenuItem by accessing the FillPrimitive contained in the item. Consider the code snippet below:

((FillPrimitive)this.radMenuItem1.Children[0]).BackColor = Color.Red; 

Don't hesitate to contact us if you have other questions.

 
Regards,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
General Discussions
Asked by
Bryan Brannon
Top achievements
Rank 2
Answers by
Bryan Brannon
Top achievements
Rank 2
Jack
Telerik team
Share this question
or