Right Alignment

4 posts, 1 answers
  1. William
    William avatar
    55 posts
    Member since:
    Sep 2008

    Posted 20 Nov 2008 Link to this post

    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.

  2. Answer
    Nikolay avatar
    1805 posts

    Posted 24 Nov 2008 Link to this post

    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,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. John
    John avatar
    2 posts
    Member since:
    Feb 2017

    Posted 28 Mar in reply to Nikolay Link to this post

    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
            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
        Me.mnuShowMain.Location = New Point(Me.RadMenu1.Size.Width - width - 5, 0)
        Me.mnuShowMain.ForeColor = Color.Red
    End Sub
  4. Dimitar
    Dimitar avatar
    2769 posts

    Posted 01 Apr Link to this post

    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)
    End Sub
    Private Sub RadMenu1_SizeChanged(ByVal sender As Object, ByVal e As EventArgs)
        If mnuShowMain Is Nothing Then
        End If
    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.

    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.
Back to Top