Back to Devexpress

DiagramControl.CalcHitItem(PointF) Method

windowsforms-devexpress-dot-xtradiagram-dot-diagramcontrol-dot-calchititem-x28-system-dot-drawing-dot-pointf-x29.md

latest2.9 KB
Original Source

DiagramControl.CalcHitItem(PointF) Method

Returns the diagram item located at the specified position.

Namespace : DevExpress.XtraDiagram

Assembly : DevExpress.XtraDiagram.v25.2.dll

NuGet Package : DevExpress.Win.Diagram

Declaration

csharp
public DiagramItem CalcHitItem(
    PointF diagramRelativePoint
)
vb
Public Function CalcHitItem(
    diagramRelativePoint As PointF
) As DiagramItem

Parameters

NameTypeDescription
diagramRelativePointPointF

A test point where a target element is located.

|

Returns

TypeDescription
DiagramItem

A diagram item located at the specified position.

|

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CalcHitItem(PointF) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

How-to-execute-an-arbitrary-action-when-a-diagram-item-is-clicked-winforms/CS/DXSample/Form1.cs#L22

csharp
private void diagramControl1_Click(object sender, EventArgs e) {
    var clickedItem = diagramControl1.CalcHitItem(((MouseEventArgs)e).Location);
    if (clickedItem is DiagramItem item) {

How-to-execute-an-arbitrary-action-when-a-diagram-item-is-clicked-winforms/VB/DXSample/Form1.vb#L17

vb
Private Sub diagramControl1_Click(ByVal sender As Object, ByVal e As EventArgs)
    Dim clickedItem = diagramControl1.CalcHitItem(CType(e, MouseEventArgs).Location)
    Dim item As DiagramItem = Nothing

See Also

DiagramControl Class

DiagramControl Members

DevExpress.XtraDiagram Namespace