Issue with item resizing in RTL

3 posts, 0 answers
  1. Pedram
    Pedram avatar
    2 posts
    Member since:
    Jan 2016

    Posted 30 Jan Link to this post

    Hi,

    I have a Property Grid in my form and I made this RightToLeft. the problem is that I can't resize the item Height correctly.

    The mouse cursor type should change to resize when the mouse is in the | border of item, but it doesn't work well.

    You can see this in picture.

     Thanks

  2. Pedram
    Pedram avatar
    2 posts
    Member since:
    Jan 2016

    Posted 30 Jan in reply to Pedram Link to this post

    This is Screenshot Link :

    imgur.com/GwSfXWM

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 03 Feb Link to this post

    Hello Pedram,

    Thank you for writing.

    I have logged it in our feedback portal. You can track its progress, subscribe for status changes and add your vote/comment to it on the following link - feedback item.

    I have also updated your Telerik points.

    Currently, the possible solution that I can suggest is to use custom item element:

    public Form1()
    {
        InitializeComponent();
        this.radPropertyGrid1.CreateItemElement += radPropertyGrid1_CreateItemElement;
        this.radPropertyGrid1.SelectedObject = this;
        this.radPropertyGrid1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
    }
     
    private void radPropertyGrid1_CreateItemElement(object sender, CreatePropertyGridItemElementEventArgs e)
    {
        if (e.ItemElementType == typeof(PropertyGridItemElement))
        {
            e.ItemElementType = typeof(CustomPropertyGridItemElement);
        }
    }
     
    public class CustomPropertyGridItemElement : PropertyGridItemElement
    {
        private bool isResizing;
        private Point downLocation;
        private int downWidth;
     
        protected override Type ThemeEffectiveType
        {
            get
            {
                return typeof(PropertyGridItemElement);
            }
        }
     
        private const int resizePointerOffset = 3;
     
        public override bool IsInResizeLocation(Point location)
        {
            return (location.X >= this.ControlBoundingRectangle.X + this.PropertyTableElement.ValueColumnWidth - resizePointerOffset &&
                    location.X <= this.ControlBoundingRectangle.X + this.PropertyTableElement.ValueColumnWidth + resizePointerOffset);
        }
     
        protected override void OnMouseDown(MouseEventArgs e)
        {
            if (IsInResizeLocation(e.Location))
            {
                if (this.PropertyTableElement.IsEditing)
                {
                    this.PropertyTableElement.EndEdit();
                }
     
                this.Capture = true;
                this.isResizing = true;
                this.downLocation = e.Location;
                this.downWidth = this.PropertyTableElement.ValueColumnWidth;
            }
     
            base.OnMouseDown(e);
        }
     
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (this.isResizing)
            {
                int delta = e.Location.X - downLocation.X;
     
                if (this.RightToLeft)
                {
                    delta *= -1;
                }
     
                this.PropertyTableElement.ValueColumnWidth = downWidth - delta;
                return;
            }
     
            if (this.IsInResizeLocation(e.Location))
            {
                this.ElementTree.Control.Cursor = Cursors.VSplit;
            }
            else
            {
                this.ElementTree.Control.Cursor = Cursors.Default;
            }
     
            base.OnMouseMove(e);
        }
     
        protected override void OnMouseUp(MouseEventArgs e)
        {
            if (this.isResizing)
            {
                this.isResizing = false;
                this.Capture = false;
            }
     
            base.OnMouseUp(e);
        }
    }

     

    I hope this information helps. Should you have further questions I would be glad to help.
     
    Regards,
    Dess
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top