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

Wrapping and FontSetting in MenuItems for Startmenu

8 Answers 185 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Klaus Löffelmann
Top achievements
Rank 1
Klaus Löffelmann asked on 29 Jul 2009, 11:51 AM
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

8 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 30 Jul 2009, 09:21 AM
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.
0
Peter
Telerik team
answered on 30 Jul 2009, 09:32 AM
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.
0
Klaus Löffelmann
Top achievements
Rank 1
answered on 30 Jul 2009, 09:36 AM
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
0
Peter
Telerik team
answered on 31 Jul 2009, 07:11 AM
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.
0
Klaus Löffelmann
Top achievements
Rank 1
answered on 31 Jul 2009, 07:31 AM
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

0
Jack
Telerik team
answered on 31 Jul 2009, 04:33 PM
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.
0
Brent
Top achievements
Rank 1
answered on 18 Sep 2012, 10:15 PM
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.
0
Jack
Telerik team
answered on 21 Sep 2012, 01:04 PM
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 >>
Tags
RibbonBar
Asked by
Klaus Löffelmann
Top achievements
Rank 1
Answers by
Peter
Telerik team
Klaus Löffelmann
Top achievements
Rank 1
Jack
Telerik team
Brent
Top achievements
Rank 1
Share this question
or