CommandBarDropDownButton items show up in a wrong position

2 posts, 0 answers
  1. Davut
    Davut avatar
    1 posts
    Member since:
    Feb 2017

    Posted 26 Feb Link to this post

       Hi Telerik Team,

    i begin to developing a telerik UI by using c#. i added a CommandBarDropDownButton for language selection (English & Arabic). When i set currentculture as arabic and RightToLeft to Yes, CommandBarDropDownButton items, are onthe right side of screen, show up shifted position, in a wrong position. i attached the screenshots for clarifying problem. 

    Here is my code:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Globalization;
    using System.Threading;
    using System.Windows.Forms;
    using Telerik.WinControls;
    using Telerik.WinControls.UI;
      
    namespace TelerikWinFormsApp2
    {
        public partial class Form1 : RadForm
        {
            private static RightToLeft right2Left = RightToLeft.No;
            private readonly object _locker = new object();
      
            public static CultureInfo CurrentCulture { get; set; }
      
            private RightToLeft Right2Left
            {
                get { return right2Left; }
                set {
                    if (!(right2Left == value))
                    {
                        lock(_locker){
                            right2Left = value;
                            CultureChangeFunc();
                        }
                    }
                }
            }
      
            public Form1()
            {
                InitializeComponent();
            }
      
            private void Form1_Load(object sender, EventArgs e)
            {
                InitializeToolbar();
            }
      
            private void InitializeToolbar()
            {
                bseLayout.Grip.Visibility = ElementVisibility.Collapsed;
                bseActions1.Grip.Visibility = ElementVisibility.Collapsed;
                bseLanguage.Grip.Visibility = ElementVisibility.Collapsed;
      
                bseLanguage.DesiredLocation = new PointF(10000, 0);
      
                this.commandBarDropDownButton2.Image = Image.FromFile("icons\\32x32\\icon_list.png");
                this.commandBarDropDownButton3.Image = Image.FromFile("icons\\32x32\\icon_settings.png");
                this.commandBarDropDownButton4.Image = Image.FromFile("icons\\32x32\\icon_lang.png");
                this.commandBarButton7.Image = Image.FromFile("icons\\32x32\\icon_info.png");
                this.commandBarButton4.Image = Image.FromFile("icons\\32x32\\icon_help.png");
      
            }
      
            private void rmiLanguage_Click(object sender, EventArgs e)
            {
                var selectedItem = (RadMenuItem)sender;
                if (selectedItem.Tag == null)
                    return;
      
                try
                {
                    if (selectedItem.Tag.Equals("rmiEnglish"))
                    {
                        CurrentCulture = new CultureInfo("en-US");
                        Right2Left = RightToLeft.No;
                    }
                    else if (selectedItem.Tag.Equals("rmiArabic"))
                    {
                        CurrentCulture = new CultureInfo("ar-SA");
                        Right2Left = RightToLeft.Yes;
                    }
                    else
                    {
                        return;
                    }                  
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Change Language Error : "+ ex.Message.ToString());
                }
            }
      
            private void CultureChangeFunc()
            {
                try
                {
                    Thread.CurrentThread.CurrentCulture = CurrentCulture;
                    Thread.CurrentThread.CurrentUICulture = CurrentCulture;
                    RightToLeft = Thread.CurrentThread.CurrentCulture.TextInfo.IsRightToLeft ? RightToLeft.Yes : RightToLeft.No;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Change Language Error : ", ex.Message.ToString());
                }
            }
      
      
      
        }
    }

     

    Best Regards..

     

  2. Dimitar
    Admin
    Dimitar avatar
    1871 posts

    Posted 27 Feb Link to this post

    Hi Davut,

    Thank you for writing.

    I was able to reproduce the observed issue. I have logged it in our Feedback Portal. I have added a vote for it on your behalf as well. You can track its progress, subscribe for status changes and add your comment to it here. I have also updated your Telerik Points.

    To workaround this you should set the location of the dropdown like this:
    commandBarDropDownButton3.DropDownMenu.PopupOpening += DropDownMenu_PopupOpening;
     
     
    private void DropDownMenu_PopupOpening(object sender, CancelEventArgs args)
    {
        var e = args as RadPopupOpeningEventArgs;
        var ownerElement = (sender as RadDropDownMenu).OwnerElement;
        var loc = ownerElement.ElementTree.Control.PointToScreen(ownerElement.ControlBoundingRectangle.Location);
        loc.Y += ownerElement.ControlBoundingRectangle.Height;
        loc.X -=  ((sender as RadDropDownMenu).Width - ownerElement.ControlBoundingRectangle.Width);
        e.CustomLocation = loc;
     
    }

    Should you have any other questions do not hesitate to ask.

    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top