Completed
Last Updated: 05 Feb 2016 07:07 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 03 Feb 2016 11:16
Category: PropertyGrid
Type: Bug Report
1
FIX. RadPropertyGrid - resizing cursor does not show correctly in Right to Left mode
To reproduce: use the following code snippet and refer to the attached gif file.

public Form1()
{
    InitializeComponent();
    this.radPropertyGrid1.SelectedObject = this;
    this.radPropertyGrid1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
}

Workaround:

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);
    }
}
Attached Files:
0 comments