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

RadMenuItem inheritance display issue

2 Answers 154 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Constantinos Petridis
Top achievements
Rank 1
Iron
Iron
Constantinos Petridis asked on 25 Jun 2010, 10:53 AM
I am trying to inherit RadMenuItem (sample bellow), in order to add more properties required by our application.

Public Class TestMenuItem 
    Inherits RadMenuItem 
 
    Public Sub New() 
        Me.New(""Nothing
    End Sub 
 
    Public Sub New(ByVal text As String
        Me.New(text, Nothing
    End Sub 
 
    Public Sub New(ByVal text As StringByVal tag As Object
        MyBase.New(text, tag) 
    End Sub 
End Class 

When I try to add this new RadMenuItem in a RadMenu object, the visual display of the item is different from the actual RadMenuItem. I guess it is a ThemeEngine glitch. Do you have any advice on how to correctly inherit RadMenuItem?

This is a sample form where two menu items are added, one standard RadMenuItem (test1) and one from the inherited TestMenuItem (test2). Form1 has a RadMenu control added and it is a standard Windows.Form form.
Public Class Form1 
 
    Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load 
        Dim mi1 As New RadMenuItem("test1"
        Dim mi2 As New testMenuItem("test2"
        Me.RadMenuItem1.Items.Add(mi1) 
        Me.RadMenuItem1.Items.Add(mi2) 
    End Sub 
End Class 

In the attached image you can see the resulting runtime form with the difference in visual display of the two menu items.

We are currently evaluating your WinForms controls and we have little to no experience with your libraries :).

2 Answers, 1 is accepted

Sort by
0
Accepted
Deyan
Telerik team
answered on 01 Jul 2010, 11:26 AM
Hello Constantinos,

Thanks for contacting us and for your interest in RadControls for WinForms.

Indeed, the issue that you experience is related to the theming mechanism. Our theming mechanism maps the XML styles to the elements by using their type. So, by inheriting from RadMenuItem, you introduce a new item type which is not recognizable by our mechanism. Thus, you will have to override the ThemeEffectiveType property in your new RadMenuItem type and return the type of RadMenuItem. Take a look at the code snippet below:

Protected Overrides ReadOnly Property ThemeEffectiveType() As Type
    Get
        Return GetType(RadMenuItem)
    End Get
End Property

Without this property override, your item will remain unstyled by having the default border and fill colors.

Consider this as a general approach of avoiding theming issues when inheriting from different items in our framework.

I hope this helps and will be happy to address any future inquiries regarding our control suite that you might have.

Greetings,
Deyan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Constantinos Petridis
Top achievements
Rank 1
Iron
Iron
answered on 01 Jul 2010, 12:03 PM
Thank you for your quick answer
It worked like a charm :)
Tags
Menu
Asked by
Constantinos Petridis
Top achievements
Rank 1
Iron
Iron
Answers by
Deyan
Telerik team
Constantinos Petridis
Top achievements
Rank 1
Iron
Iron
Share this question
or