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

Right Alignment

3 Answers 277 Views
Menu
This is a migrated thread and some comments may be shown as answers.
William
Top achievements
Rank 1
William asked on 20 Nov 2008, 02:15 PM
Is it possible to right align an item on the menu so that it appears totally on the right side of menu strip?  With the Status bar you can put a blank element with the property of spring and then items to the right will appear docked to the right side.

Thanks

3 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay
Telerik team
answered on 24 Nov 2008, 02:53 PM
Hi William,

Currently, RadMenuItems does not support the 'spring' feature. However, you can set the Location of the desired item so that it is placed on the far end of the RadMenu. You should do this in the RadMenu_SizeChanged event. I have demonstrated the approach in the sample project attached.

If you have additional questions, feel free to contact me.

Kind regards,
Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
John
Top achievements
Rank 1
answered on 28 Mar 2019, 03:00 PM

This doesn't seem to work in WIn10 Pro - I am developing on Win7 Pro and it does work, but when deployed to a WIn10 machine the menu item doesn't move until you actually resize the from width.  And even to get it to work in WIn7 I had to catch the form_Shown event and resize the for - oh yeah, the menu is being created dynamically in the form.Load event because it has a radDropDown and radButton and a radCheckBox

 

'============== MENU ITEMs ==============
 
''' <summary>
''' DropDown Menu Item for additional Filtering by column
''' </summary>
Private mnuFilterCol As RadDropDownList
''' <summary>
''' Search Box Menu Item
''' </summary>
Private radFilterText As RadTextBoxElement
 
''' <summary>
''' CheckBox menu item
''' </summary>
Private chkShowSearchBar As RadCheckBoxElement
 
''' <summary>
''' Keeps track of the previous VISIBLE status of the Search Bar
''' </summary>
Private m_fchkShowSearchBar_Clicked As Boolean
 
''' <summary>
''' CheckBox menu item
''' </summary>
Private cmdCollapseAll As RadButtonElement
 
''' <summary>
''' Right handed menu item
''' </summary>
Private mnuShowMain As RadMenuItem
 
Private Sub frmListV3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
 
    Try
        Call SetWaitCursor()
 
        Me.MinimumSize = New Size(Me.Width, Me.Height)
        Me.Width = CInt(GetSetting(Application.ProductName, Me.Name.Substring(3), TableType.ToString() & "_Width", Width.ToString())) - 5
        Me.Height = CInt(GetSetting(Application.ProductName, Me.Name.Substring(3), TableType.ToString() & "_Height", Me.Height.ToString()))
 
        '============================================================================
        ' Finish our menu - since it doesn't appear to be able to be done in the IDE
        Dim menuContentItem As RadMenuContentItem
 
        menuContentItem = New RadMenuContentItem()
        mnuFilterCol = New RadDropDownList
        mnuFilterCol.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown
        'mnuFilterCol.AutoCompleteDataSource = AutoCompleteSource.ListItems
        mnuFilterCol.AutoCompleteMode = AutoCompleteMode.SuggestAppend
        Dim menuHostItem As New RadMenuHostItem(mnuFilterCol)
        menuHostItem.PositionOffset = New SizeF(50, 0)
        Call RadMenu1.Items.Add(menuHostItem)
 
        menuContentItem = New RadMenuContentItem()
        radFilterText = New RadTextBoxElement()
        radFilterText.TextBoxItem.NullText = "Quick Filter"
        radFilterText.MinSize = New Size(100, 0)
        menuContentItem.ContentElement = radFilterText
        menuContentItem.PositionOffset = New SizeF(100, 0)
        Call RadMenu1.Items.Add(menuContentItem)
 
        menuContentItem = New RadMenuContentItem()
        chkShowSearchBar = New RadCheckBoxElement
        chkShowSearchBar.Text = "Show Search Bar"
        chkShowSearchBar.ToolTipText = "Toggles the grid search bar visibility"
        chkShowSearchBar.AutoSize = True
        menuContentItem.ContentElement = chkShowSearchBar
        menuContentItem.PositionOffset = New SizeF(150, 0)
        Call RadMenu1.Items.Add(menuContentItem)
 
        menuContentItem = New RadMenuContentItem()
        cmdCollapseAll = New RadButtonElement
        cmdCollapseAll.Text = "Collapse All"
        cmdCollapseAll.ToolTipText = "Collapse all row groups"
        cmdCollapseAll.AutoSize = True
        menuContentItem.ContentElement = cmdCollapseAll
        menuContentItem.PositionOffset = New Size(200, 0)
        Call RadMenu1.Items.Add(menuContentItem)
 
        mnuShowMain = New RadMenuItem("Show Main")
        Call RadMenu1.Items.Add(mnuShowMain)
 
        '======================= END OF MENU =========================
 
 
        Call InitializeGrid()
 
        m_iSearchCol = mnuFilterCol.Items.Count - 1 ' i.e. ALL
        mnuFilterCol.SelectedIndex = m_iSearchCol
 
    Catch ex As Exception
        Dim sCaption = "frmListV3.Load()"
        Call Connector.LogMessage(sCaption, ex.Message,, ex)
        Call MsgBox(ex.Message, MsgBoxStyle.Critical, sCaption)
 
    End Try
 
    Call WireEvents()
 
 
    Call Me.CenterToScreen()
    Call SetWaitCursor(False)
 
    Call Me.Show()
 
    If TableType = Connector.DB.Table_Type.eWorkOrder Then
        Dim descriptor As New GroupDescriptor()
        Call descriptor.GroupNames.Add("Status", ListSortDirection.Ascending)
        Call dgvList.GroupDescriptors.Add(descriptor)
    End If
 
End Sub
 
''' <summary>
''' HACK: To force right hand menu to adjust
''' </summary>
Private Sub frmListV3_Shown(sender As Object, e As EventArgs)
    Me.Width += 5
    Call dgvList.MasterTemplate.CollapseAll()
End Sub
 
Private Sub RadMenu1_SizeChanged(sender As Object, e As EventArgs)
 
    If mnuShowMain Is Nothing Then Exit Sub
 
    Dim width As Integer = 0
    For Each item In RadMenu1.Items
        width += item.Size.Width
    Next
 
    Me.mnuShowMain.Location = New Point(Me.RadMenu1.Size.Width - width - 5, 0)
    Me.mnuShowMain.ForeColor = Color.Red
 
End Sub
0
Dimitar
Telerik team
answered on 01 Apr 2019, 11:10 AM
Hi John,

Until the form is shown the menu items size is not updated. This is why you need to update the location when the form is shown. In addition, you can use the Margin instead of the location (the location will not trigger the proper layout events and this approach is valid for the old versions of the WinForms suite - before 2011). Here is an example:
Protected Overrides Sub OnShown(ByVal e As EventArgs)
    MyBase.OnShown(e)
    UpdateSize()
End Sub
Private Sub RadMenu1_SizeChanged(ByVal sender As Object, ByVal e As EventArgs)
    If mnuShowMain Is Nothing Then
        Return
    End If
    UpdateSize()
End Sub
Private Sub UpdateSize()
    Dim width As Integer = 0
    For Each item In RadMenu1.Items
        width += item.Size.Width
    Next item
 
    Dim leftPadding As Integer = Me.RadMenu1.Size.Width - width - 5
    Me.mnuShowMain.Margin = New Padding(leftPadding, 0, 0, 0)
    Me.mnuShowMain.ForeColor = Color.Red
End Sub

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Get quickly onboard and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Menu
Asked by
William
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
John
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or