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

Double click row

7 Answers 355 Views
GanttView
This is a migrated thread and some comments may be shown as answers.
Pasi
Top achievements
Rank 1
Pasi asked on 14 Dec 2017, 03:37 PM

Hello.

I am quite new to UI programming (and Telerik components) and thus have a question about double clicking. The problem is as follows.
We have a need to start some handling when user double clicks on an item. This should happen from either side of the gantt view, from the grid or timeline side.
My current implementation is such that I subscribe for radGanttView DoubleClick-event. In the event handler I check from radGanttView SelectedItem-property which item was double clicked. The problem here is that if the item is already selected, user can double click anywhere and my code will be run.
So the question is as follows. Is there a way to receive a double click only if user clicks on the UI element of the task? It seems that GanttGraphicalViewBaseTaskElement has a doubleclick-event but I don't know how to get my hands on such object. Or should this be done somehow differently?

Thank you!
br.Pasi

Using:
Progress 11.6
Telerik UI for Winforms R2 2017

7 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 Dec 2017, 06:39 AM
Hello, Pasi,

Thank you for writing.  

Here is  a sample code snippet demonstrating how to detect double clicking over GanttViewTaskElement in the graphical view: 
this.radGanttView1.MouseDoubleClick+=radGanttView1_MouseDoubleClick;


private void radGanttView1_MouseDoubleClick(object sender, MouseEventArgs e)
{
    GanttViewTaskElement element = this.radGanttView1.ElementTree.GetElementAtPoint(e.Location) as GanttViewTaskElement;
    if (element !=null)
    {
        Console.WriteLine(element.Text);
    }
}

I hope this information helps. Should you have further questions I would be glad to help.
 
Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Pasi
Top achievements
Rank 1
answered on 15 Dec 2017, 11:07 AM

Hello Dess and thank you for the quick reply.

I tried this out but I'm getting the following exception: System.Reflection.AmbiguousMatchException: Ambiguous match found.

My code is as follows.

THIS-OBJECT:radGanttView1:MouseDoubleClick:Subscribe(THIS-OBJECT:MouseDoubleClickEventHandler).

 

METHOD PRIVATE VOID MouseDoubleClickEventHandler(
    INPUT iSender AS System.Object,
    INPUT iArgs   AS System.Windows.Forms.MouseEventArgs ):
 
    DEFINE VARIABLE xLocation    AS System.Drawing.Point                             NO-UNDO.
    DEFINE VARIABLE xElementTree AS Telerik.WinControls.ComponentThemableElementTree NO-UNDO.
    DEFINE VARIABLE xRadElement  AS Telerik.WinControls.RadElement                   NO-UNDO.
     
     
    xLocation = iArgs:Location.     
    MESSAGE "X:" STRING(xLocation:X) " Y:" STRING(xLocation:Y) VIEW-AS ALERT-BOX. /* This is shown */
     
    xElementTree = THIS-OBJECT:radGanttView1:ElementTree.
     
    MESSAGE "Getting element." VIEW-AS ALERT-BOX. /* This is shown */
     
    /* This seems to cause the following error:
      System.Reflection.AmbiguousMatchException: Ambiguous match found. */
    xRadElement = xElementTree:GetElementAtPoint(INPUT xLocation).
             
    MESSAGE "This does not show up" VIEW-AS ALERT-BOX.
 
END METHOD.

 

Any ideas what could cause this and is there something I could do differently?

Thank you!

 

b.r. Pasi

 

 

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 Dec 2017, 12:15 PM
Hello, Pasi, 

Thank you for writing back. 

I have attached my sample C# project where everything works as expected. If you are experiencing any difficulties with ABL and the OpenEdge environment feel free to submit your case in Salesforce by using the following link: https://progresslink.progress.com/
Thus the OpenEdge support will gladly assist you.

I hope this information helps. If you have any additional questions, please let me know. 

 Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Pasi
Top achievements
Rank 1
answered on 15 Dec 2017, 12:50 PM

Once again, thank you for the quick reply Dess! I will continue through Salesforce.

b.r. Pasi

0
Pasi
Top achievements
Rank 1
answered on 21 Dec 2017, 01:01 PM

Hello again Dess!

It seems that there is a problem with call to GetElementAtPoint when using the libraries from Progress.

https://knowledgebase.progress.com/articles/Article/Reflection-error-calling-Telerik-GetElementAtPoint-method

 

Before we get a fix for this, is there any other way to implement the check for what was double clicked? (And we would need it for both sides, for the grid and timeline.) Or should we just stick to the current implementation until we get the fix?

 

Thank you again for the help.

B.r. Pasi

0
Hristo
Telerik team
answered on 22 Dec 2017, 01:31 PM
Hello Pasi,

Thank you for writing.

Indeed OpenEdge has an issue with generic methods and until this gets resolved you will not be able to use the built-in implementation. You can perform the same check this way: 
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
 
        this.radGanttView1.MouseDown += RadGanttView1_MouseDown;
    }
 
    private void RadGanttView1_MouseDown(object sender, MouseEventArgs e)
    {
        RadElement el = this.GetElementAtPoint(this.radGanttView1, this.radGanttView1.RootElement, e.Location, null);
    }
 
    public RadElement GetElementAtPoint(Control control, RadElement parent, Point point, List<RadElement> foundElements)
    {
        if (parent.Visibility != ElementVisibility.Visible)
        {
            return null;
        }
 
        ChildrenListOptions childrenFlags = ChildrenListOptions.ZOrdered | ChildrenListOptions.ReverseOrder | ChildrenListOptions.IncludeOnlyVisible;
 
        Rectangle client = control.ClientRectangle;
 
        foreach (RadElement element in parent.GetChildren(childrenFlags))
        {
            if (element.ElementState != ElementState.Loaded)
            {
                continue;
            }
 
            if (element.HitTest(point))
            {
                bool addElement = (foundElements != null) && !(element is BorderPrimitive);
 
                if (addElement)
                {
                    foundElements.Add(element);
                }
 
                RadElement res = GetElementAtPoint(control, element, point, foundElements);
 
                if (res != null)
                {
                    return res;
                }
 
                if (element.ShouldHandleMouseInput)
                {
                    return element;
                }
            }
        }
 
        return null;
    }
}

I hope this helps. Please let me know if you need further assistance.

Regards,
Hristo
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Pasi
Top achievements
Rank 1
answered on 03 Jan 2018, 08:42 AM

Hello Hristo! Thank you for the example and help with the issue! I got this working now as required.

br. Pasi

Tags
GanttView
Asked by
Pasi
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Pasi
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or