Wrapping and FontSetting in MenuItems for Startmenu

9 posts, 0 answers
  1. Klaus Löffelmann
    Klaus Löffelmann avatar
    3 posts
    Member since:
    Jul 2009

    Posted 29 Jul 2009 Link to this post

    Hello,

    we are just evaluating the performance of the telerik rad-controls for a rather large migration project (vb6 to VS2008, > 1.500.000 lines of code)and played around a little bit with the test version.

    Concerning the RibbonbarControl:

    • Is it possible to automatically let the description text of a start menu item (e.g. done in excel or word) wrap to several lines?
    • We tried to set the font property of a start menu's sub-menuitem different to the description text, but it won't get applied (namely: Text Font is Bold, Description Font non bold). Would that be possible?

    (Like it is done in Microsoft Excel, when you open the save sub-menu. You see that every menu item there is bold and the description is non bold. The description text on top of that gets wrapped if it doesn't fit in the line. This is essential behaviour for a ribbon bar's start menu, isn't it?)

    Thanks,

    Klaus

  2. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 30 Jul 2009 Link to this post

    Hi Klaus Löffelmann,

    Thank you for your interest in RadControls.

    The RadMenuItem description text currently not support this scenario to wrap text automatically.
    As a workaround you could place manually vbNewLine in the text.

    Regards,
    Peter
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 30 Jul 2009 Link to this post

    Hi Klaus Löffelmann,

    About the second question you could customize the description text using the RadMenuItem.DescriptionFont property. For example:

    Dim item As RadMenuItem = TryCast(Me.radRibbonBar1.StartMenuItems(0), RadMenuItem) 
    item.DescriptionFont = New Font(SystemFonts.DialogFont, FontStyle.Italic) 
     
     

    I will be glad to help you with the migration to RadRibbonBar. Don't hesitate to contact us if you have other questions.

    Greetings,
    Peter
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Klaus Löffelmann
    Klaus Löffelmann avatar
    3 posts
    Member since:
    Jul 2009

    Posted 30 Jul 2009 Link to this post

    Thanks for the workaround!

    We did that already and that worked.
    Having said that, would you have any suggestions for the "bold-issue"?
    Why can't we apply the bold fontweight to the MenuItem-Text?
    Setting the font doesn't seem to have any effect.

    We don't want to have the description text in bold, but the actual MenuItem-Text.

    Thanks!

    Klaus Löffelmann
    www.activedevelop.de
    Microsoft MVP Visual Basic .NET
  6. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 31 Jul 2009 Link to this post

    Hello Klaus Löffelmann,

    I attached a sample project that demonstrates how to wrap description text and how to apply different fonts to menu text and to description text. You have to bear in mind that RadMenu does not support scrolling. I hope this helps.

    Regards,
    Peter
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. Klaus Löffelmann
    Klaus Löffelmann avatar
    3 posts
    Member since:
    Jul 2009

    Posted 31 Jul 2009 Link to this post

    Peter,

    thanks for the quick response - I really appreciate.

    But, yet again, it doesn't explain or help with the problem we are facing.

    To be completely precise in pointing out the issue: If I modify the code you provided, why does the font assignment to the actual menu item (see code) not work? Only through this we could provide the same look and feel as provided in excel or word.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    For i = 1 To 3

    Dim menuItem As RadMenuItem = New RadMenuItem

    menuItem.Text = "Menu item " & Str(i)

    'Why does this not work???

     

    menuItem.Font = New Font(menuItem.Font, FontStyle.Bold)

    menuItem.DescriptionText = "Long text text text text text text text text text text text text text" & Str(i)

    Me.FixDescriptionTextLen(menuItem)

    TryCast(menuItem.Children(2).Children(0).Children(1).Children(0), TextPrimitive).Font = New Font(Control.DefaultFont, FontStyle.Underline)

    menuItem.DescriptionFont = New Font(Control.DefaultFont, FontStyle.Italic)

    Me.RadRibbonBar1.StartMenuItems.Add(menuItem)

    Next i

    End Sub

    Thanks,

    Klaus
    www.activeDevelop.de
    Microsoft MVP Visual Basic .NET

  8. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 31 Jul 2009 Link to this post

    Hi Klaus,

    This is an issue related with our theming mechanism. Currently the Font property of the menu item is not bound with the text primitive used to show the menu text. We will consider changing this behavior in one of our upcoming releases. You can change the non-working line in your code with this one:

    menuItem.Layout.Text.Font = New Font(Control.DefaultFont, FontStyle.Italic) 

    Should you have any further questions, we will be glad to help.

    Best wishes,
    Jack
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  9. Brent
    Brent avatar
    2 posts
    Member since:
    Oct 2010

    Posted 18 Sep 2012 Link to this post

    Please note that when you use vbNewLine to wrap the text, this makes it almost impossible to split your text out into a resource file since in the resource file you cannot add your vbnewlines.  You essentially have to create your own wrapping mechanism that reads the resource file and then feeds the wrapped text to the control.  This is a real pain the royal rear.
  10. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 21 Sep 2012 Link to this post

    Hi Brent,

    I am not sure that I fully understand the issue. Yes, you cannot insert line breaks when adding a string resource through the settings dialog. However it is easy to add a string resource file. Follow these steps:

    1. Add a new text file in your project and enter some text in it.
    2. Go to the properties panel and change its Build Action to be Embedded Resource.
    3. Use the following code to load the text and assign it to a button:
    Dim fileText As String
    Dim a As Assembly = GetType(Form1).Assembly
    Using reader As New StreamReader(a.GetManifestResourceStream("TicketTestVB.Resource.txt"))
        fileText = reader.ReadToEnd()
    End Using
     
    Me.RadButton1.TextWrap = True
    Me.RadButton1.Text = fileText

    If this does not help or if you have further questions, do not hesitate to ask.
     
    Greetings,
    Jack
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready