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

Issue with item resizing in RTL

2 Answers 49 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Pedram
Top achievements
Rank 1
Pedram asked on 30 Jan 2016, 05:01 PM

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 Answers, 1 is accepted

Sort by
0
Pedram
Top achievements
Rank 1
answered on 30 Jan 2016, 05:51 PM

This is Screenshot Link :

imgur.com/GwSfXWM

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 03 Feb 2016, 01:41 PM
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
Tags
PropertyGrid
Asked by
Pedram
Top achievements
Rank 1
Answers by
Pedram
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or